public class TestList {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add(1234);
list.add(456);
list.add(new String("张三"));
list.add(new Phone("李四",23));
list.add(false);
System.out.println(list);
list.add(1,"BB");
System.out.println(list);
list.add(789);
System.out.println(list);
int index = list.indexOf(456);
System.out.println(index);
Object obj = list.remove(0);
System.out.println(obj);
System.out.println(list);
list.set(1,"CC");
System.out.println(list);
List sublist = list.subList(2,4);
System.out.println(sublist);
System.out.println(list);
}
}
List代码
最新推荐文章于 2021-01-28 21:19:48 发布