OnJava8-Examples/generics/Manipulation.java
Bruce Eckel 49edcc8b17 reorg
2015-06-15 17:47:35 -07:00

20 lines
503 B
Java

//: generics/Manipulation.java
// ©2015 MindView LLC: see Copyright.txt
// {CompileTimeError} (Will not compile)
class Manipulator<T> {
private T obj;
public 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();
}
} /* Output: (None) *///:~