-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathManipulation.java
More file actions
37 lines (29 loc) · 801 Bytes
/
Manipulation.java
File metadata and controls
37 lines (29 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package generics;
import java.util.*;
/**
* RUN:
* javac generics/Manipulation.java && java generics.Manipulation
* OUTPUT:
*
*/
public class Manipulation {
public static void main(String[] args) {
HasF hf = new HasF();
Manipulator<HasF> manipulator = new Manipulator<HasF>(hf);
manipulator.manipulate();
}
}
class Manipulator<T> {
private T obj;
public Manipulator(T x) { obj = x; }
/**
* error: cannot find symbol
* public void manipulate() { obj.f(); }
* ^
* symbol: method f()
* location: variable obj of type T
* where T is a type-variable:
* T extends Object declared in class Manipulator
*/
public void manipulate() { obj.f(); }
}