Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ef9863

Browse files
committed
Fixed issue BruceEckel#46
1 parent a75a55d commit 5ef9863

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

generics/Diamond.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
55

6-
class Bob {}
7-
86
public class Diamond<T> {
97
public static void main(String[] args) {
10-
GenericHolder<Bob> h3 = new GenericHolder<>();
11-
h3.set(new Bob());
8+
GenericHolder<Automobile> h3 =
9+
new GenericHolder<>();
1210
}
1311
}

generics/GenericHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public GenericHolder() {}
1010
public T get() { return a; }
1111
public static void main(String[] args) {
1212
GenericHolder<Automobile> h3 =
13-
new GenericHolder<>();
13+
new GenericHolder<Automobile>();
1414
h3.set(new Automobile()); // type checked
1515
Automobile a = h3.get(); // No cast needed
1616
//- h3.set("Not an Automobile"); // Error

0 commit comments

Comments
 (0)