package generics; import net.mindview.util.*; /** * RUN: * javac generics/TupleTest.java && java generics.TupleTest * OUTPUT: * (hi, 47) * (generics.Amphibian@422ede, hi, 47) * (generics.Vehicle@110b053, generics.Amphibian@a83b8a, hi, 47) * (generics.Vehicle@a981ca, generics.Amphibian@8814e9, hi, 47, 11.1) */ public class TupleTest { static TwoTuple f() { return new TwoTuple("hi", 47); } static ThreeTuple g() { return new ThreeTuple(new Amphibian(), "hi", 47); } static FourTuple h() { return new FourTuple( new Vehicle(), new Amphibian(), "hi", 47 ); } static FiveTuple k() { return new FiveTuple( new Vehicle(), new Amphibian(), "hi", 47, 11.1 ); } public static void main(String[] args) { TwoTuple ttsi = f(); System.out.println(ttsi); // error: cannot assign a value to final variable first // ttsi.first = "there"; System.out.println(g()); System.out.println(h()); System.out.println(k()); } } class Amphibian {} class Vehicle {}