I'm reading a book at it cites the following:
With primitive variables, an assignment of one variable to another means the contents (bit pattern) of one variable are copied into another...The contents of a reference variable are a bit pattern...
Please help me understand what 'bit pattern' means here. Is that another way of saying the memory address of a variable?
For example, what could the bit patterns look like for the following two variables
So, for example if "int x = 4" and that 4 resides at memory address X77348 then what gets copied to the other reference? 00000100 (which is 4 in binary)? or the X77348
Not the memory address of the primitive variables. The contents of the memory address of the primitive variable.
Likewise, with a reference it's the contents of the memory address of the reference variable. (Remember that behind the scenes a Java reference is essentially a pointer. So the "bit pattern" with respect to a reference is that pointer (which points to wherever on the heap the object lives)).