创建对象的数组列表
如何用对象填充 ArrayList,其中每个对象都是不同的?
ArrayList<Matrices> list = new ArrayList<Matrices>();
list.add( new Matrices(1,1,10) );
list.add( new Matrices(1,2,20) );
创建一个数组来存储对象:
ArrayList<MyObject> list = new ArrayList<MyObject>();
只需一个步骤:
list.add(new MyObject (1, 2, 3)); //Create a new object and adding it to list.
或
MyObject myObject = new MyObject (1, 2, 3); //Create a new object.
list.add(myObject); // Adding it to the list.