public class ArrayBag<T>{
    //private T[] content=new T[10]; //编译出错，不能用泛型来创建数组实例
    private T[] content;

    public ArrayBag(T[] content) {
        this.content = content;
    }

    public T[] get() {
        return this.content;
    }

    public void set(T[] content) {
        this.content = content;
    }

    public static void main(String[] args){

      String[] content={"book1","book2","book3"};
      ArrayBag<String> bag=new ArrayBag<String>(content);
 
      for(String c:bag.get())
        System.out.println(c);
    }
}


/****************************************************
 * 作者：孙卫琴                                     *
 * 来源：<<Java面向对象编程>>                       *
 * 技术支持网址：www.javathinker.net                *
 ***************************************************/
