Collection之List接口

List接口继承Collection接口,包含LinkedList和ArrayList接口,且有顺序可以重复

package com.study;

import java.util.*;

public class TestCollectionList {

	public void doList() {
		
		Collection cList = new ArrayList();
		cList.add("zhudansheng");
		cList.add(new Boolean(true));
		
		System.out.println(cList);
		
		List list = new ArrayList();	//List 接口是有顺序,且可以重复的数据值
		list.add("123");
		list.add("456");
		list.add("789");
		
		for(int i=0;i<10;i++) {
			list.add(i);
		}
		
		System.out.println(list);
		
		System.out.println("list.get(1)============="+list.get(1));
		System.out.println("list.set(2)============="+list.set(2,"33333"));
		System.out.println(list);
		list.remove(1);
		System.out.println(list);
	}
	
	public static void main(String []args) {
		TestCollectionList list = new TestCollectionList();
		list.doList();
	}
}

 

你可能感兴趣的:(Collection)