欢迎来到天天文库
浏览记录
ID:21105237
大小:41.50 KB
页数:5页
时间:2018-10-19
《测试List和Set》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、----------专业最好文档,专业为你服务,急你所急,供你所需-------------文档下载最佳的地方importjava.util.ArrayList;importjava.util.HashSet;importjava.util.Iterator;importjava.util.LinkedList;importjava.util.Random;importjava.util.TreeSet;importcom.sun.org.apache.bcel.internal.generic.NEW;/***@AuthorLies*@Descripti
2、on*@Createdat2013-7-30上午10:47:52*//***@AuthorLies*@Description*@Createdat2013-7-30上午10:47:52*/publicclassTest{publicstaticvoidArryList(){ArrayListarrayList1=newArrayList();//add(Objecto);StringstrList="arrayList";for(inti=0;i<6;i++){arrayList1.add(strList+i);}//iterator()No.1/*Ite
3、ratorit=arrayList1.iterator();while(it.hasNext()){System.out.print("++++++Iterator_CLASS++++++");System.out.println(it.next());}*///iterator()No.2/*while(arrayList1.iterator().hasNext()){System.out.print("+++Object+++++");System.out.println(arrayList1.iterator().next());//????????
4、?thereisendlessloop!!!!whay?//System.out.print("+++String+++++");//System.out.println(arrayList1.iterator().next().toString());}*///remove(Objecto);NO.1Think:howtoremvoevalue=arraylist4?arrayList1.remove(2);//remove(index);//System.out.println(arrayList1.get(3));----------专业最好文档,专
5、业为你服务,急你所急,供你所需-------------文档下载最佳的地方----------专业最好文档,专业为你服务,急你所急,供你所需-------------文档下载最佳的地方Iteratorit=arrayList1.iterator();/*while(it.hasNext()){System.out.print("++++++Iterator_CLASS++++++");System.out.println(it.next());}*//*arrayList1.remove(arrayList1.get(3));//remove(Object
6、o);while(it.hasNext()){System.out.print("++++++Iterator_CLASS++++++");System.out.println(it.next());}*/}publicstaticvoidlinkedListTest(){//---newLinkedList();LinkedListlinkedlist1=newLinkedList();Stringstr1="LinedList++";for(inti=0;i<6;i++){//linkedlist1.add(str1+i);//linkedlist1.
7、addFirst(str1+i);linkedlist1.addLast(str1+i);}/*Iteratorit=linkedlist1.iterator();//:::::Testbuildinglinkedlist1success?while(it.hasNext()){System.out.print("++++++Iterator_CLASS++++++");System.out.println(it.next());}*///linkedlist1.remove();//:::::removefirstelement;//linkedlist
8、1.remove(2);//::::remove(index):r
此文档下载收益归作者所有