Fixed issue #46
This commit is contained in:
parent
a75a55dc81
commit
5ef986390e
@ -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<T> {
|
||||
public static void main(String[] args) {
|
||||
GenericHolder<Bob> h3 = new GenericHolder<>();
|
||||
h3.set(new Bob());
|
||||
GenericHolder<Automobile> h3 =
|
||||
new GenericHolder<>();
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class GenericHolder<T> {
|
||||
public T get() { return a; }
|
||||
public static void main(String[] args) {
|
||||
GenericHolder<Automobile> h3 =
|
||||
new GenericHolder<>();
|
||||
new GenericHolder<Automobile>();
|
||||
h3.set(new Automobile()); // type checked
|
||||
Automobile a = h3.get(); // No cast needed
|
||||
//- h3.set("Not an Automobile"); // Error
|
||||
|
Loading…
x
Reference in New Issue
Block a user