liner09136
发贴: 6
积分: 0
|
于 2005-09-12 19:58
package collection; import java.util.*;
public class ListTest { public ListTest(){ } public static void test(){ List list = new ArrayList();//如果有一天 list.add(new Student(2,"Tom")); list.add(new Student(3,"Bonny")); list.add(new Student(7,"Jack")); list.add(new Student(4,"Steven")); list.add(new Student(5,"Smith")); list.add(new Student(6,"Jane")); List linkedList = new LinkedList(list); list.set(1,new Student(3,"NewBonny")); System.out.println(linkedList); } public static void main(String[] args) { ListTest.test(); } } 其中这一句 list.set(1,new Student(3,"NewBonny"));并不改变list中的值,小弟刚开始学java,理解的不是很深刻,请大家指教!
|