No, when assigning primitive values, do not create any objects.
May concern you the fact that primitive values ββcan be automatically placed in appropriate wrappers when they are used in a context where a reference type (for example, "object") is required:
int i = 13; // this line does not create an object Integer i2 = i; // at this line 13 is auto-boxed into an Integer object char c = 'x'; // again: no object created: List<Character> l = new ArrayList<Character>(); l.add(c); // c is auto-boxed into a Character object
In addition, I will try to describe the difference between declaration and initialization:
int i; // an int-variable is declared int j = 0; // an int-variable is declared and initialized i = 1; // an int-variable is assigned a value, this is *not* initialization
The variable is "declared" when it is created for the first time (that is, the type and name of the variable are indicated). It is initialized when it is assigned a value during the declaration.
source share