|
How many objects are there in this picture? How many reference variables are there in this picture? A good answer might be:There are two objects, and two reference variables, each containing a different reference. | |
Equality of Reference Variable ContentsThe == operator is used to look at the contents of two reference variables. (This operator is two equal signs in a row.) If the contents of both reference variables is the same, then the result is true. Otherwise the result is false. The == operator does NOT look at objects! It only looks at references (information about where an object is located.)
Here is a section from the previous program, with an additional
Since the reference in strA is different than the reference in strB,
is false. (Look at the picture on the previous page.) The third output statement will not execute. | |
QUESTION 13:Did the == operator look at the contents of the objects when the if statement executed? Click Here after you have answered the question |