Skip to content

Commit 2f4108d

Browse files
committed
fix
1 parent 15d5a5f commit 2f4108d

3 files changed

Lines changed: 26 additions & 23 deletions

File tree

‎generics/ErasureAndInheritance.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Derived2 extends GenericBase {} // No warning
1919
// required: class or interface without bounds
2020

2121
public class ErasureAndInheritance {
22-
@SuppressWarnings("unchecked")
22+
// @SuppressWarnings("unchecked")
2323
public static void main(String[] args) {
2424
Derived2 d2 = new Derived2();
2525
Object obj = d2.get();

‎generics/ListMaker.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
public class ListMaker<T> {
88
List<T> create() { return new ArrayList<>(); }
99
public static void main(String[] args) {
10-
ListMaker<String> stringMaker = new ListMaker<>();
10+
// ListMaker<String> stringMaker = new ListMaker<>();
11+
ListMaker<String> stringMaker = new ListMaker<String>();
1112
List<String> stringList = stringMaker.create();
1213
}
1314
}

‎generics/Manipulation.java‎

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
//// generics/Manipulation.java
2-
//// (c)2021 MindView LLC: see Copyright.txt
3-
//// We make no guarantees that this code is fit for any purpose.
4-
//// Visit http://OnJava8.com for more book information.
5-
//// {WillNotCompile}
6-
//
7-
//class Manipulator<T> {
8-
// private T obj;
9-
// Manipulator(T x) { obj = x; }
10-
// // Error: cannot find symbol: method f():
11-
// public void manipulate() { obj.f(); }
12-
//}
13-
//
14-
//public class Manipulation {
15-
// public static void main(String[] args) {
16-
// HasF hf = new HasF();
17-
// Manipulator<HasF> manipulator =
18-
// new Manipulator<>(hf);
19-
// manipulator.manipulate();
20-
// }
21-
//}
1+
// generics/Manipulation.java
2+
// (c)2021 MindView LLC: see Copyright.txt
3+
// We make no guarantees that this code is fit for any purpose.
4+
// Visit http://OnJava8.com for more book information.
5+
// {WillNotCompile}
6+
7+
class Manipulator<T> {
8+
private T obj;
9+
Manipulator(T x) { obj = x; }
10+
// Error: cannot find symbol: method f():
11+
public void manipulate() {
12+
// obj.f();
13+
}
14+
}
15+
16+
public class Manipulation {
17+
public static void main(String[] args) {
18+
HasF hf = new HasF();
19+
Manipulator<HasF> manipulator =
20+
new Manipulator<>(hf);
21+
manipulator.manipulate();
22+
}
23+
}

0 commit comments

Comments
 (0)