2015-04-20 15:36:01 -07:00
|
|
|
|
//: generics/GenericHolder.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
|
|
|
|
|
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 =
|
2015-05-05 11:20:13 -07:00
|
|
|
|
new GenericHolder<>();
|
2015-04-20 15:36:01 -07:00
|
|
|
|
holder.set("Item");
|
|
|
|
|
String s = holder.get();
|
|
|
|
|
}
|
|
|
|
|
} ///:~
|