16 lines
505 B
Java
16 lines
505 B
Java
// generics/SimpleHolder.java
|
|
// (c)2016 MindView LLC: see Copyright.txt
|
|
// We make no guarantees that this code is fit for any purpose.
|
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
|
|
|
public class SimpleHolder {
|
|
private Object obj;
|
|
public void set(Object obj) { this.obj = obj; }
|
|
public Object get() { return obj; }
|
|
public static void main(String[] args) {
|
|
SimpleHolder holder = new SimpleHolder();
|
|
holder.set("Item");
|
|
String s = (String)holder.get();
|
|
}
|
|
}
|