/** Class ObjectRefTest. Demo of object variables (references) @author A. Ozgelen */ public class ObjectRefTest { public static void main(String[] args) { Coin x = new Coin(); x.flip(); System.out.println("x: " + x); Coin y; y = x; System.out.println("y: " + y); x.flip(); System.out.println("x.getFace():" + x.getFace()); System.out.println("y.getFace():" + y.getFace()); Pocket p = new Pocket(3); System.out.println(p); p.getFaceOfCoin(1); Pocket p2 = new Pocket(); // would have been a NullPointerException if the // Pocket.getFaceOfCoin didn't properly handle its input int face1 = p2.getFaceOfCoin(0); System.out.println("Face value of the first coin in my pocket: " + face1); // ArrayIndexOutOfBoundsException int face2 = p2.getFaceOfCoin(11); } }