The Interface and Class Hierarchy Diagram of Java Collections

1. Collection vs Collections

First of all, “Collection” and “Collections” are two different concepts. As you will see from the hierarchy diagram below, “Collection” is a root interface in the Collection hierarchy but “Collections” is a class which provide static methods to manipulate on some Collection types.

2. Class hierarchy of Collection

The following diagram demonstrates class hierarchy of Collection.

3. Class hierarchy of Map

Here is class hierarchy of Map.

4. Summary of classes

collection-summary

5. Code Example

The following is a simple example to illustrate some collection types:

List<String> a1 = new ArrayList<String>();
a1.add("Program");
a1.add("Creek");
a1.add("Java");
a1.add("Java");
System.out.println("ArrayList Elements");
System.out.print("\t" + a1 + "\n");
 
List<String> l1 = new LinkedList<String>();
l1.add("Program");
l1.add("Creek");
l1.add("Java");
l1.add("Java");
System.out.println("LinkedList Elements");
System.out.print("\t" + l1 + "\n");
 
Set<String> s1 = new HashSet<String>(); // or new TreeSet() will order the elements;
s1.add("Program");
s1.add("Creek");
s1.add("Java");
s1.add("Java");
s1.add("tutorial");
System.out.println("Set Elements");
System.out.print("\t" + s1 + "\n");
 
Map<String, String> m1 = new HashMap<String, String>(); // or new TreeMap() will order based on keys
m1.put("Windows", "2000");
m1.put("Windows", "XP");
m1.put("Language", "Java");
m1.put("Website", "programcreek.com");
System.out.println("Map Elements");
System.out.print("\t" + m1);

Output:

ArrayList Elements
	[Program, Creek, Java, Java]
LinkedList Elements
	[Program, Creek, Java, Java]
Set Elements
	[tutorial, Creek, Program, Java]
Map Elements
	{Windows=XP, Website=programcreek.com, Language=Java}

174 thoughts on “The Interface and Class Hierarchy Diagram of Java Collections”

  1. Pingback: sv388aduayam.com
  2. Pingback: login sv388
  3. Pingback: locksmiths
  4. Pingback: GlucoProven Review
  5. Pingback: Annica Skin Serum
  6. Pingback: Gluco Proven
  7. Pingback: high Bay Lights
  8. Pingback: view site…
  9. Pingback: Discuss
  10. Pingback: joker-123.co.com
  11. Pingback: Login dewibola
  12. Pingback: click here
  13. Pingback: collect gifts
  14. Pingback: company website
  15. Pingback: Blaux Heater 450w
  16. Pingback: teeth Whitening
  17. Pingback: Going Here
  18. Pingback: Stop Toothache
  19. Pingback: dental implant
  20. Pingback: anchor
  21. Pingback: Children's Teeth
  22. Pingback: Netcallvoip.com
  23. Pingback: Solar In Orlando
  24. Pingback: bookingcare.vn
  25. Pingback: small acts
  26. Pingback: st louis dentists
  27. Pingback: Military Care
  28. Pingback: ambbet
  29. Pingback: right wall color
  30. Pingback: Dental Plymouth mn
  31. Pingback: Dental treatment
  32. Pingback: Marianne Beaty
  33. Pingback: allbet
  34. Pingback: iphone
  35. Pingback: astutamme saamarin
  36. Pingback: Xtreme Keto Lean
  37. Pingback: quesnit.in
  38. Pingback: Web3 Gaming
  39. Pingback: mom
  40. Pingback: my company
  41. Pingback: free games
  42. Pingback: planet Earth
  43. Pingback: similar webpage
  44. Pingback: Read Even more
  45. Pingback: baby Teething toys
  46. Pingback: yourlisten.com
  47. Pingback: Sweetdate.Space
  48. Pingback: Treat Baby
  49. Pingback: artnames.info
  50. Pingback: sbobet88
  51. Pingback: fishnut.ca
  52. u missed the abstractinterface,such as abstractcollection,abstractset,abstractlist,Those are important in the hierarchy of java collection.

Leave a Comment