freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

java編程異常處理ppt課件-資料下載頁(yè)

2025-10-07 23:41本頁(yè)面
  

【正文】 組 ,保證元素不重復(fù) LinkedHashSet繼承自 HashSet底層用雙向鏈表實(shí)現(xiàn) TreeSet可對(duì)集合中的元素進(jìn)行排序 ,要存放在 TreeSet中的對(duì)象 ,要么是已經(jīng)實(shí)現(xiàn)了 Comparable接口 ,要么能給出 Comparator比較器 .會(huì)根據(jù)比較規(guī)則判斷元素內(nèi)容是否相同 ,TreeSet會(huì)在元素存入時(shí)就進(jìn)行排序 . HashMap,key是無(wú)序存放的 ,也是不可以重復(fù)的 ,key與 value一一對(duì)應(yīng)的 ,線程不安全的 . Hashtable與 HashMap比較相似 ,也是線程安全的 ,不允許 key和value為 null LinkedHashMap與 LinkedHashSet很相似 TreeMap會(huì)按照 key進(jìn)行排序 ,和 TreeSet類(lèi)一樣 ,在使用自定義類(lèi)作 key時(shí) ,要用自定義類(lèi)實(shí)現(xiàn) Comparable接口 Collection類(lèi) : 1. import .*。 2. public class TestCollection 3. { 4. public static void main(String[] args) 5. { 6. Collection c = new HashSet()。 7. (java)。 8. (String)。 9. (home)。 10. //(12)。 11. (new String(path))。 12. (new String(path))。 13. (new StringBuffer(String))。 14. (new StringBuffer(String))。 15. (())。 16. ((java))。 17. (())。 18. ((java))。 19. (c)。 20. Iterator it = ()。 21. while(()){ 22. (()+ )。 23. } 24. ()。 25. /* 26. Object[] obj = ()。 27. for(Object o:obj){ 28. (o)。 29. } 30. */ 31. } 32. } Set接口及 HashSet類(lèi) : 1. import .*。 2. public class TestSet 3. { 4. public static void main(String[] args) 5. { 6. Set s1 = new HashSet()。 7. Set s2 = new HashSet()。 8. (add)。 9. (String)。 10. (hello)。 11. (String)。 12. (add)。 13. (world)。 14. Set s3 = new HashSet(s1)。 15. (s2)。 16. Set s4 = new HashSet(s1)。 17. (s2)。 18. (s3)。 19. (s4)。 20. } 21. } SortedSet接口及時(shí)性 TreeSet類(lèi) : 1. public class Person /*implements Comparable */ 2. { 3. private int id。 4. private String name。 5. public void setId(int id){ 6. = id。 7. } 8. public int getId(){ 9. return 。 10. } 11. public void setName(String name){ 12. = name。 13. } 14. public String getName(){ 15. return 。 16. } 17. 18. /* 19. public int pareTo(Object o){ 20. if(o instanceof Person){ 21. Person p = (Person)o。 22. return ()。 23. }else{ 24. return 0。 25. } 26. } 27. */ 28. 29. public String toString(){ 30. return ()+ +()。 31. } 32. 33. } 測(cè)試類(lèi) 1: 1. import .*。 2. public class TestPerson 3. { 4. public static void main(String[] args) 5. { 6. SortedSet ss = new TreeSet()。 7. Person p1 = new Person()。 8. (2)。 9. (yi)。 10. Person p2 = new Person()。 11. (3)。 12. (zhou)。 13. Person p3 = new Person()。 14. (5)。 15. (wen)。 16. (p1)。 17. (p2)。 18. (p3)。 19. (ss)。 20. } 21. } 測(cè)試類(lèi) 2: 1. import .*。 2. public class TestSortedSet 3. { 4. public static void main(String[] args) 5. { 6. SortedSet ss = new TreeSet(new Comparator(){ 7. public int pare(Object o1,Object o2){ 8. if(o1 instanceof Person amp。amp。 o2 instanceof Person){ 9. Person p1 = (Person)o1。 10. Person p2 = (Person)o2。 11. return ()()。 12. }else{ 13. return 0。 14. } 15. } 16. })。 17. 18. Person p1 = new Person()。 19. (2)。 20. (yi)。 21. Person p2 = new Person()。 22. (3)。 23. (zhou)。 24. Person p3 = new Person()。 25. (5)。 26. (won)。 27. (p1)。 28. (p2)。 29. (p3)。 30. (ss)。 31. } 32. } ArrayList類(lèi) : 1. import .*。 2. public class TestList 3. { 4. public static void main(String[] args) 5. { 6. ArrayList list = new ArrayList()。 7. String n1 = one。 8. String n2 = two。 9. String n3 = three。 10. int n4 = 4。 11. String n5 = three。 12. (n1)。 13. (n2)。 14. (n3)。 15. (n4)。 16. (n5)。 17. (list)。 18. for(int i= 0。i()。i++){ 19. Object o = (i)。 20. (o)。 21. } 22. } 23. } Vector類(lèi) : 1. import .*。 2. public class TestVector 3. { 4. public static void main(String[] args) 5. { 6. Vector v = new Vector()。 7. for(int i = 0。i50。i++){ 8. ((i))。 9. } 10. for(int i = 50。i100。i++){ 11. ((99i+50))。 12. } 13. (v+ )。 14. } 15. } Map接口及 HashMap類(lèi) : Map接口 : 1. import .*。 2. public class TestMap 3. { 4. public static void main(String[] args) 5. { 6. Map m = new HashMap()。 7. ((805),Tom)。 8. (803,Tom)。 9. (803,yidong)。 10. (804,Jerry)。 11. (801,Lucy)。 12. (802,Jc)。 13. Set s = ()。 14. Iterator it = ()。 15. while(()){ 16. Object key = ()。 17. Integer i = (Integer)key。 18. String ss = (String)(i)。 19. (ss+ )。 20. } 21. } 22. } HashMap類(lèi) : 1. import .*。 2. public class TestHashMap 3. { 4. public static void main(String[] args) 5. { 6. HashMap hm = new HashMap()。 7. ((805),Tom)。 8. (803,Tom)。 9. (804,Jerry)。 10. (801,Lucy)。 11. (802,Jc)。 12. //(hm)。 13. (802)。 14. (hm)。 15. Object o = (804)。 16. String s = (String)o。 17. (s)。 18. } 19. }
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1