@Test public void testMultiGenerics(){ GenericExample<String> example = new GenericExample<>(); GenericExample.MyPair<String, Integer> pair = example.createPair("foo", 5); assertNotNull(pair); assertEquals("foo", pair.x); assertEquals((Integer)5, pair.y); GenericExample.MyPair<String, String> other = example.createPair("foo", "bar"); assertNotNull(other); assertEquals("foo", other.x); assertEquals("bar", other.y); }
public <Z> MyPair<T,Z> createPair(T t, Z z){ MyPair<T, Z> pair = new MyPair<>(t, z); return pair; }
GenericExample { public <Z> MyPair<T,Z> createPair(T t, Z z){ MyPair<T, Z> pair = new MyPair<>(t, z); return pair; } }
GenericExample { public <Z> MyPair<T,Z> createPair(T t, Z z){ MyPair<T, Z> pair = new MyPair<>(t, z); return pair; }  }
GenericExample { public <Z> MyPair<T,Z> createPair(T t, Z z){ MyPair<T, Z> pair = new MyPair<>(t, z); return pair; }  Object identityObject(Object x); T identityGeneric(T x); Z identityGenericOnMethod(T t, Z z); MyPair<T,Z> createPair(T t, Z z); Comparable max(Comparable x, Comparable y); Z maxWithGenerics(Z x, Z y); }
GenericExample { public <Z> MyPair<T,Z> createPair(T t, Z z){ MyPair<T, Z> pair = new MyPair<>(t, z); return pair; }  Object identityObject(Object x); T identityGeneric(T x); Z identityGenericOnMethod(T t, Z z); MyPair<T,Z> createPair(T t, Z z); Comparable max(Comparable x, Comparable y); Z maxWithGenerics(Z x, Z y);  }