A reference

R

Robert Mark Bram

Howdy All!

int number = 3;
Object obj = new Object();

Would I correct in saying:
- as a primitive, the value of number is 3;
- as an object reference, the value of obj is a "reference" to the object
variable created on the rest of the line.

Thus..

int number1 = 3;
int number2 = 3;
Object obj1 = new Object();
Object obj2 = new Object();

number1 == number2;
True because their values are equal (3 == 3).

obj1 == obj2;
False because their values are different (obj1's value is a reference to the
first object: obj2's value is a reference to the second object).

Thanks for any assistance!

Rob
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top