//ArrayList
{
ArrayList arraylist=new ArrayList();
arraylist.add(0,"end");//指定索引加入值
//需注意的是,如果現(xiàn)有2個(gè)值,我加入索引為5的那么就會出現(xiàn)異常
for(int i=0;i<2;i++){
arraylist.add(i,String.valueOf(i));
}
System.out.println("ArrayList:");
for(int i=0;i System.out.print(arraylist.get(i)+";"); } arraylist.add("0");//直接加入值到ArrayList的最后 arraylist.add("0"); System.out.print("\nArrayList\'s lastIndexOf(\"0\") is "+arraylist.lastIndexOf("0")); } //Arrays { String []array=new String[]{"a","b","c"}; List list=Arrays.asList(array); System.out.println("\nArrays:"); for(int i=0;i System.out.print(list.get(i)+";"); } System.out.print("\nArrays\'s length is "+array.length);//打印數(shù)組的長度 } //Collections { String []array=new String[]{"a","b","c"}; List list=Arrays.asList(array); Collections.fill(list,"Fill");//用Fill填充全部元素 System.out.println("\nCollections:"); for(int i=0;i System.out.print(list.get(i)+";"); } array=new String[]{"1","2","3"}; List list2=Arrays.asList(array); Collections.copy(list,list2);//拷貝list2的數(shù)據(jù)進(jìn)list System.out.println("\n"+list); Collections.swap(list,2,1);//調(diào)換索引為1和2的元素的位置 System.out.println(list); } //EventObject { String s="hello"; String s2=s; EventObject eventobject=new EventObject(s);//一個(gè)準(zhǔn)容器類型,確切的歸類它不是容器 System.out.println("EventObject:"); System.out.println(eventobject.getSource()); System.out.println(eventobject.equals(s2)); } //HashMap { HashMap hashmap=new HashMap();//一個(gè)速度最快的容器 hashmap.put("0","c"); hashmap.put("1","a"); hashmap.put("2","b"); hashmap.put("3","a"); System.out.println("HashMap:"); System.out.println(hashmap);//該容器有其內(nèi)部的排序方式 Set set=hashmap.keySet();//獲取全部鍵 Iterator iterator=set.iterator(); while(iterator.hasNext()){ System.out.print(hashmap.get(iterator.next())+";"); } } //HashSet { HashSet hashset=new HashSet();//一個(gè)絕對不能重復(fù)的類型 hashset.add("c"); hashset.add("b"); hashset.add("a"); hashset.add("a"); hashset.add("b"); System.out.println("\nHashSet:"); System.out.println(hashset); Iterator iterator=hashset.iterator();//取出元素 while(iterator.hasNext()){ System.out.print(iterator.next()+";"); } } //Hashtable { Hashtable hashtable=new Hashtable();//一個(gè)完全可以由其他容器替換的老容器類型 hashtable.put("0","c"); hashtable.put("1","a"); hashtable.put("3","c"); hashtable.put("2","b"); System.out.println("\nHashtable:"); Enumeration enumeration=hashtable.elements();//獲取元素,Enumeration已經(jīng)不是主流,Iterator是它的下一代替代品 while(enumeration.hasMoreElements()){ System.out.print(enumeration.nextElement()+";"); } } //IdentityHashMap { IdentityHashMap identityhashmap=new IdentityHashMap(); identityhashmap.put("0","c"); identityhashmap.put("1","a"); identityhashmap.put("3","b"); identityhashmap.put("2","a"); System.out.println("\nIdentityHashMap:"); System.out.println(identityhashmap); System.out.println(identityhashmap.containsKey("3"));//是否包含這個(gè)鍵 System.out.println(identityhashmap.containsValue("a"));//是否包含值 Set set=identityhashmap.entrySet();//傳為Set類型 System.out.println(set); set=identityhashmap.keySet();//全部鍵 System.out.println(set); } //LinkedHashMap { LinkedHashMap linkedhashmap=new LinkedHashMap(); linkedhashmap.put("0","b"); linkedhashmap.put("2","a"); linkedhashmap.put("1","c"); linkedhashmap.put("3","b"); System.out.println("LinkedHashMap:"); System.out.println(linkedhashmap); System.out.println(linkedhashmap.containsKey("2"));//是否包含這個(gè)鍵 System.out.println(linkedhashmap.containsValue("c"));//是否包含值 Set set=linkedhashmap.keySet(); Iterator iterator=set.iterator(); while(iterator.hasNext()){ System.out.print(linkedhashmap.get(iterator.next())+";"); } } //LinkedHashSet { LinkedHashSet linkedhashset=new LinkedHashSet();//它包含了幾種Set的屬性但卻沒有自己的特色 linkedhashset.add("c"); linkedhashset.add("a"); linkedhashset.add("a"); linkedhashset.add("b"); System.out.println("\nLinkedHashSet:"); System.out.println(linkedhashset); System.out.println(linkedhashset.contains("a"));//是否包含對象 Iterator iterator=linkedhashset.iterator(); while(iterator.hasNext()){ System.out.print(iterator.next()+";"); } } //LinkedList { LinkedList linkedlist=new LinkedList();//自由使用是它的特色 linkedlist.add("a"); linkedlist.add(1,"c"); linkedlist.addLast("b"); linkedlist.addFirst("d"); System.out.println("\nLinkedList:"); System.out.println(linkedlist); //linkedlist.clear();//該方法清空容器 //linkedlist.remove(0);//刪除索引為0的元素 //linkedlist.remove("d");//刪除值為d的元素 //linkedlist.removeFirst();//刪除第一個(gè)元素 //linkedlist.removeLast();//刪除最后一個(gè)元素 for(int i=0;i System.out.print(linkedlist.get(i)+";"); } } //Stack { Stack stack=new Stack();//堆棧 stack.add("b"); stack.add(0,"c"); stack.push("d"); stack.add("e"); stack.push("a"); Enumeration enumeration=stack.elements(); System.out.println("\nStack:"); while(enumeration.hasMoreElements()){ System.out.print(enumeration.nextElement()+";"); } //后進(jìn)先出 System.out.println("\n"+stack.peek()); System.out.println(stack.pop()); System.out.println(stack.contains("d")+";"+stack.contains("a"));//是否包含該元素,有趣的事情發(fā)生了 System.out.println(stack.search("c"));//非常有用的屬性,檢索,但是由后向前的排列 } //TreeMap { TreeMap treemap=new TreeMap(); treemap.put("0","d"); treemap.put("2","a"); treemap.put("1","b"); treemap.put("3","c"); System.out.println("\nTreeMap:");//可以對鍵排序 System.out.println(treemap); System.out.println(treemap.firstKey());//返回第一個(gè)鍵 Set set=treemap.keySet(); Iterator iterator=set.iterator(); while(iterator.hasNext()){ System.out.print(treemap.get(iterator.next())+";"); } } //TreeSet { TreeSet treeset=new TreeSet();//自動(dòng)排序內(nèi)容 treeset.add("b"); treeset.add("a"); treeset.add("c"); treeset.add("d"); System.out.println("\nTreeSet:"); System.out.println(treeset); System.out.println(treeset.first());//返回第一個(gè)元素 Iterator iterator=treeset.iterator(); while(iterator.hasNext()){ System.out.print(iterator.next()+";"); } } //Vector { Vector vector=new Vector(); vector.add(0,"b"); vector.add("a"); vector.addElement("d"); vector.add("c"); System.out.println("\nVector:"); System.out.println(vector); vector.set(2,"h");//替換掉指定索引的元素 System.out.println(vector); Object []str=vector.toArray(); for(int i=0;i System.out.print(str[i]+";"); } vector.setSize(2);//重新設(shè)置大小為2 System.out.println("\n"+vector); } //WeakHashMap { WeakHashMap weakhashmap=new WeakHashMap(); weakhashmap.put("1","b"); weakhashmap.put("2","c"); weakhashmap.put("0","d"); weakhashmap.put("3","a"); System.out.println("\nWeakHashMap:"); System.out.println(weakhashmap); System.out.println(weakhashmap.containsKey("3"));//是否包含鍵 System.out.println(weakhashmap.containsValue("d"));//是否包含值 Set set=weakhashmap.entrySet(); Iterator iterator=set.iterator(); while(iterator.hasNext()){ System.out.print(iterator.next()+";"); } //weakhashmap.remove("2");//刪除該鍵對應(yīng)的值 //weakhashmap.get("1");//獲取指定鍵的值 } }
初級會計(jì)職稱中級會計(jì)職稱經(jīng)濟(jì)師注冊會計(jì)師證券從業(yè)銀行從業(yè)會計(jì)實(shí)操統(tǒng)計(jì)師審計(jì)師高級會計(jì)師基金從業(yè)資格稅務(wù)師資產(chǎn)評估師國際內(nèi)審師ACCA/CAT價(jià)格鑒證師統(tǒng)計(jì)資格從業(yè)
一級建造師二級建造師消防工程師造價(jià)工程師土建職稱房地產(chǎn)經(jīng)紀(jì)人公路檢測工程師建筑八大員注冊建筑師二級造價(jià)師監(jiān)理工程師咨詢工程師房地產(chǎn)估價(jià)師 城鄉(xiāng)規(guī)劃師結(jié)構(gòu)工程師巖土工程師安全工程師設(shè)備監(jiān)理師環(huán)境影響評價(jià)土地登記代理公路造價(jià)師公路監(jiān)理師化工工程師暖通工程師給排水工程師計(jì)量工程師
人力資源考試教師資格考試出版專業(yè)資格健康管理師導(dǎo)游考試社會工作者司法考試職稱計(jì)算機(jī)營養(yǎng)師心理咨詢師育嬰師事業(yè)單位教師招聘公務(wù)員公選考試招警考試選調(diào)生村官
執(zhí)業(yè)藥師執(zhí)業(yè)醫(yī)師衛(wèi)生資格考試衛(wèi)生高級職稱護(hù)士資格證初級護(hù)師主管護(hù)師住院醫(yī)師臨床執(zhí)業(yè)醫(yī)師臨床助理醫(yī)師中醫(yī)執(zhí)業(yè)醫(yī)師中醫(yī)助理醫(yī)師中西醫(yī)醫(yī)師中西醫(yī)助理口腔執(zhí)業(yè)醫(yī)師口腔助理醫(yī)師公共衛(wèi)生醫(yī)師公衛(wèi)助理醫(yī)師實(shí)踐技能內(nèi)科主治醫(yī)師外科主治醫(yī)師中醫(yī)內(nèi)科主治兒科主治醫(yī)師婦產(chǎn)科醫(yī)師西藥士/師中藥士/師臨床檢驗(yàn)技師臨床醫(yī)學(xué)理論中醫(yī)理論