Java_List_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > Java_List

Java_List

 2014/5/2 16:08:29  JavaBlogs  程序员俱乐部  我要评论(0)
  • 摘要:List<String>l1=newArrayList<String>();List<String>l2=newLinkedList<String>();add(intindex,Objectobj);set(intindex,Objectobj);publicstaticvoidmain(String[]args){Stringa="A",b="B",c="C",d="D",e="E";List<String>
  • 标签:list Java
class="java">List<String>l1 = new ArrayList<String>();
List<String>l2 = new LinkedList<String>();

add(int index, Object obj);
set(int index, Object obj);

public static void main(String[]args){
	String a = "A", b = "B", c = "C", d = "D", e = "E";
	List<String> list = new LinkedList<String>();
	list.add(a);
	list.add(e);
	list.add(d);
	list.set(1, b);//将索引位置为1的对象e修改为对象b
	list.add(2, c);//将对象c添加到索引位置为2的位置
	Iterator<String> it = list.Iterator();

	while(it.hasnext()){
		System.out.println(it.next());
	}
}

for (int i = 0; i < list.size(); i++ ) {
	System.out.println(list.get(i));
}

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.List;
public class TestCollection{
	public static void main(String[]args){
		System.out.println("开始:");
		String a = "A", b = "B", c = "C", d = "D", e = "E";
		List<String> list = new LinkedList<String>();
		list.add(a);
		list.add(e);
		list.add(d);
		list.set(1, b);
		list.add(2, c);
		Iterator<String> it = list.iterator();
		while(it.hasnext()){
			System.out.println(it.next());
		}
		for (int i = 0; i < list.size() ; i++) {
			System.out.println(list.get(i));
		}
		System.out.println("结束!");
	}
}

public static void main(String[]args){
	String a = "A", b = "B", c = "C", d = "D",repeat = "Repeat";
	List<String>list = new LinkedList<String>();
	list.add(a);
	list.add(repeat);
	list.add(b);
	list.add(repeat);
	list.add(c);
	list.add(repeat);
	list.add(d);
	System.out.println(list.indexOf(repeat));
	System.out.println(list.lastIndexOf(repeat));
	System.out.println(list.indexOf(b));
	System.out.println(list.lastIndexOf(b));
	System.out.println("结束!");
}

public static void main(String[]args){
	String a = "A", b = "B", c = "C", d ="D", e = "E";
	List<String> list = new ArrayList<String>();
	list.add(a);
	list.add(b);
	list.add(c);
	list.add(d);
	list.add(e);
	list = list.subList(1, 3);//利用从索引位置1到3的对象重新生成一个List集合
	for (int i = 0; i < lst.size() ;i++ ) {
		System.out.println(list.get(i));
	}
}


List list = new LinkedList();
list = new ArrayList();

list.add(0, "b");
list.add(list.size(),  "any");
b = list.remove("b");
b = list.remove(0);

String[] strArray = new String[]{"z","a","C"};
List list = Arrays.asList(strArray);


Collections.sort(list);
Collections.sort(list,String.CASE_INSENSITIVE_ORDER);

Collections.sort(list,Collections.reverseOrder());
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
Collections.reverse(list);

list1.retainAll(list2);
list1.subList(newSize,list1.size());
list.add();
Array.asList();
Collections.sort();
Collections.reverseOrder();
Collections.reverse();
list.addAll();
list.retainAll();
list.subList(size1,size2);

?

上一篇: stripes spring annotation 下一篇: 没有下一篇了!
发表评论
用户名: 匿名