Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a bit pattern?

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

  1. int x;
  2. TimeClass time;
  3. Integer y;

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

like image 914
dido Avatar asked Apr 21 '26 20:04

dido


1 Answers

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)).

like image 172
QuantumMechanic Avatar answered Apr 23 '26 21:04

QuantumMechanic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!