OnJava8-Examples/generics/Manipulation.java
2017-05-01 14:33:10 -06:00

22 lines
570 B
Java

// generics/Manipulation.java
// (c)2017 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// {WillNotCompile}
class Manipulator<T> {
private T obj;
Manipulator(T x) { obj = x; }
// Error: cannot find symbol: method f():
public void manipulate() { obj.f(); }
}
public class Manipulation {
public static void main(String[] args) {
HasF hf = new HasF();
Manipulator<HasF> manipulator =
new Manipulator<>(hf);
manipulator.manipulate();
}
}