diff --git a/generics/Diamond.java b/generics/Diamond.java index c7daa484..9ebc43d3 100644 --- a/generics/Diamond.java +++ b/generics/Diamond.java @@ -3,11 +3,9 @@ // We make no guarantees that this code is fit for any purpose. // Visit http://OnJava8.com for more book information. -class Bob {} - public class Diamond { public static void main(String[] args) { - GenericHolder h3 = new GenericHolder<>(); - h3.set(new Bob()); + GenericHolder h3 = + new GenericHolder<>(); } } diff --git a/generics/GenericHolder.java b/generics/GenericHolder.java index b04aa17a..15cfbb9e 100644 --- a/generics/GenericHolder.java +++ b/generics/GenericHolder.java @@ -10,7 +10,7 @@ public class GenericHolder { public T get() { return a; } public static void main(String[] args) { GenericHolder h3 = - new GenericHolder<>(); + new GenericHolder(); h3.set(new Automobile()); // type checked Automobile a = h3.get(); // No cast needed //- h3.set("Not an Automobile"); // Error