2.5. Object Aliases

An object can be referred by several references, meaning that they store the reference value of the same object. Such references are called aliases. The object can be manipulated via any one of its aliases, as each one refers to the same object.

			package javatutorial;

			 * Object Aliases example
			 * @author f5java.com
			public class ObjectAliasExample {

				public static void main(String[] args) {
					Car car1 = new Car(); // 1. car1 is referencing Car object
					Car car2 = car1; // 2. car2 is referencing car1 which in turn references to Car Object

					// 3. car1 & car2 are called object aliases as both refer to same object
					// notice the output below
					System.out.println("Calling method using car1 reference");
					System.out.println("Calling method using car2 reference");