DEV Community

Cover image for Collections in java
Shahed Abdulwahab
Shahed Abdulwahab

Posted on • Edited on

1 1 1 1 1

Collections in java

Alt Text

Collections:

Put all your eggs in one basket and watch that basket.
-Mark Twain

Collection: is a data structure for holding elements.
Collection<T>: is the highest level of the java's framework for collection.

-Two main interfaces that extend Collection<T> interface:
1.Set<T> interface:

  1. Does not allow duplication
  2. Does not impose an order on the elements

2.List<T> interface: (Allow duplication)

  1. Allow duplication
  2. Impose an order on the elements Alt Text

-Two Abstract classes used (for convenience) to implement Set<T> and List<T> interface:
1.AbstractSet<T>
2.AbstractList<T>

Alt Text

-Another Abstract class implements Collection<T> interface which is AbstractCollection<T>, and it is a skeleton class for the Collection<T> interface
Alt Text

-If you want a class that implement The Set<t> interface, use the class HashSet<T>
HashSet<T>: is the concrete class implements the Set interface.
It can be used as a base class if you want to implement the Set interface.
-It is implemented using a hash table.
Alt Text

-If you want a concrete class that implement The List<t> interface, use
either the class ArrayList<T> or Vector<T>
They can be used as a base class if you want to implement the Set interface using your own class.
Alt Text

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay