| 4 | // Visit http://OnJava8.com for more book information. |
| 5 | |
| 6 | public class GenericHolder<T> { |
| 7 | private T a; |
| 8 | public GenericHolder() {} |
| 9 | public void set(T a) { this.a = a; } |
| 10 | public T get() { return a; } |
| 11 | public static void main(String[] args) { |
| 12 | GenericHolder<Automobile> h3 = |
| 13 | new GenericHolder<>(); |
| 14 | h3.set(new Automobile()); // type checked |
| 15 | Automobile a = h3.get(); // No cast needed |
| 16 | //- h3.set("Not an Automobile"); // Error |
| 17 | //- h3.set(1); // Error |
| 18 | } |
| 19 | } |
nothing calls this directly
no outgoing calls
no test coverage detected