//Topic07 Generic Programming P.4 class Pair { public T first; public T second; public Pair() { } public Pair(T x1, T x2) { first = x1; second = x2; } @Override public String toString() { return "(1)" + first + " (2)" + second; } } public class Main { public static void main(String[] args) { System.out.println("Demo Pair (Objects)\n====================="); Pair p0 = new Pair(); Pair p1 = new Pair("hello", "cheers"); Pair p5 = new Pair(123, "cheers"); System.out.println(p0); // (1)null (2)null System.out.println(p1); // (1)hello (2)cheers System.out.println(p5); // (1)123 (2)cheers System.out.println(p1.first.getClass().toString()); System.out.println(p5.first.getClass().toString()); System.out.println(p1.second.getClass().toString()); System.out.println(p5.second.getClass().toString()); } }