// Example 106 from page 79 of Java Precisely second edition (The MIT Press 2005) // Author: Peter Sestoft (sestoft@itu.dk) import java.util.Date; class Pair { public final T fst; public final U snd; public Pair(T fst, U snd) { this.fst = fst; this.snd = snd; } } class Example106 { public static void main(String[] args) { Pair p1 = new Pair("Niels", 1947); Pair p2 = new Pair(2.718, 1); Pair p3 = new Pair(new Date(), "now"); System.out.println("(" + p1.fst + ", " + p1.snd + ")"); System.out.println("(" + p2.fst + ", " + p2.snd + ")"); System.out.println("(" + p3.fst + ", " + p3.snd + ")"); } }