next up previous
Next: Immutable objects Up: Unit 02 Previous: Accessibility of objects

References to objects

The new operator creates new instances of objects.

Example:

String s1 = new String ("test");
String s2 = new String ("test");
String t1 = "test";
String t2 = "test";

The references s1 and s2 are references to different objects, while t1 and t2 are references to the same object.


next up previous
Next: Immutable objects Up: Unit 02 Previous: Accessibility of objects