点击运行
public class Box
{ private T t; public void add(T t) { this.t = t; } public T get() { return t; } public static void main(String[] args) { Box
integerBox = new Box
(); Box
stringBox = new Box
(); integerBox.add(new Integer(10)); stringBox.add(new String("迹忆客")); System.out.printf("整型值为 :%d\n\n", integerBox.get()); System.out.printf("字符串为 :%s\n", stringBox.get()); } }
运行结果 :
正在执行...