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}

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

  1. When seeking legal assistance in Karachi, Pakistan, look no further than the esteemed Lawyers in Karachi Pakistan Renowned for their expertise and dedication, these legal professionals offer a comprehensive range of services to address your legal needs effectively. Whether you require representation in civil matters, guidance on corporate law issues, or advocacy in criminal cases, lawyers in Karachi, Pakistan, stand ready to provide personalized support tailored to your specific situation.

  2. Discover the benefits of using Reusable Period Product in Brampton, ON These eco-friendly alternatives to disposable menstrual products offer a sustainable and cost-effective solution for managing your menstrual cycle. Made from high-quality materials, reusable period products are designed to provide comfort, reliability, and long-term savings. Whether you prefer menstrual cups, cloth pads, or period underwear, Brampton offers a variety of options to meet your needs and support a greener lifestyle.

  3. A Chain Link Fence is a versatile and practical fencing option commonly used in residential, commercial, and industrial settings. It consists of interlocking metal links, forming a durable and transparent barrier.

  4. Each of our Belleville Used Cars undergoes a rigorous inspection process to ensure it meets our high standards for quality and reliability. We understand that peace of mind is essential when purchasing a pre-owned vehicle, which is why we go above and beyond to ensure that every car on our lot is in top condition.

  5. CBD Vape Canada is a popular method of consuming CBD, a non-psychoactive compound found in cannabis plants. Vaping CBD involves using an electronic device, also known as a vape pen or vaporizer, to inhale CBD vapor. This method is preferred by many people due to its fast onset time and ease of use.

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

Leave a Comment