is declaring/initializing primitives the same as creating new objects? from what i know when we create primitives, we also creating wrapper classes for them. im implementing on java btw.
is declaring/initializing primitives the same as creating new objects? from what i know when
Share
No, assigning primitive values does not create any objects.
What you might be referring to is the fact that primitive values can be auto-boxed into the corresponding wrappers, when they are used in a context where a reference type (a.k.a “an object”) is required:
Also, I’ll try to describe the difference between declare and initialize:
A variable is “declared” when it is created for the first time (i.e. you specify the type and name of the variable). It is initialized when it’s assigned a value during declaration.