OnJava8-Examples/generics/GenericHolder.java
2015-09-07 11:44:36 -06:00

16 lines
387 B
Java

// generics/GenericHolder.java
// ©2015 MindView LLC: see Copyright.txt
public class GenericHolder<T> {
private T obj;
public void set(T obj) { this.obj = obj; }
public T get() { return obj; }
public static void main(String[] args) {
GenericHolder<String> holder =
new GenericHolder<>();
holder.set("Item");
String s = holder.get();
}
}
/* Output: (None) */