We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a75a55d commit 5ef9863Copy full SHA for 5ef9863
2 files changed
generics/Diamond.java
@@ -3,11 +3,9 @@
3
// We make no guarantees that this code is fit for any purpose.
4
// Visit http://OnJava8.com for more book information.
5
6
-class Bob {}
7
-
8
public class Diamond<T> {
9
public static void main(String[] args) {
10
- GenericHolder<Bob> h3 = new GenericHolder<>();
11
- h3.set(new Bob());
+ GenericHolder<Automobile> h3 =
+ new GenericHolder<>();
12
}
13
generics/GenericHolder.java
@@ -10,7 +10,7 @@ public GenericHolder() {}
public T get() { return a; }
GenericHolder<Automobile> h3 =
- new GenericHolder<>();
+ new GenericHolder<Automobile>();
14
h3.set(new Automobile()); // type checked
15
Automobile a = h3.get(); // No cast needed
16
//- h3.set("Not an Automobile"); // Error
0 commit comments