public class AliasingDemo { public static void main(String[] args) { Bug flik = new Bug(); Bug atta = new Bug(Color.GREEN, 90, 1, 2); System.out.println(flik.getLocation()); // (0, 0) flik = atta; // aliasing System.out.println(flik.getLocation()); // (1, 2) flik = null; //System.out.println(flik.getLocation()); // Null Exception error System.out.println(atta.getLocation()); // (1, 2) flik = new Bug(); // Bug flik = new Bug(); would cause error since // you can't redeclare flik a 2nd time in the program even though you can re-instantiate flik System.out.println(flik.getLocation()); // (0, 0) // System.out.println(flik.myColor); // can't access private properties flik.setLocation(atta.getLocation()); System.out.println(flik.getLocation()); // (1, 2) } }