Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 813573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:22:57+00:00 2026-05-15T01:22:57+00:00

We find a lot of concrete subclasses under Collection . While trying to add

  • 0

We find a lot of concrete subclasses under Collection.

While trying to add an element in a concrete collection, this collection will use a method to determine if it can accept to store the element (and eventually that this element is not already in the collection).
It could use equals(), hashCode() or compareTo() of the element.

Is it possible to find a summary about which method is used by each implementation of Collection ?

Thanks a lot for your answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:22:58+00:00Added an answer on May 15, 2026 at 1:22 am

    First of all not all collections check whether the element you’re adding already exists in the collection. For example ArrayList just appends the element to the tail of the list, without checking if it’s already in the list. Other classes use equals if the collection is guaranteed to have only one copy of the object, or compareTo, if the elements are supposed to be Comparable and the collection is sorted (to find the right place to insert it at). Maps will also use equals to check for the key, but some like HashMap will also use hashCode() to speed up the searching process (they first get all keys with the same hashcode, and then use equals on each of them to find if the key already exists and has a value assigned, which will then get replaced).

    But if you want to see how they work you can check out the sources that are included with the jdk.
    In eclipse I have the JRE set to the folder where the jdk is installed, and I can use CTRL+SHIFT+T to open any class (type) in the jdk, CTRL+click the name of a class, or for methods, even CTRL+click -> open implementation, which opens a pop up with the classes the implement that method (if it’s from an interface, or the method directly in the class, if it’s not)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While studying the Collection API, we find that some methods ( add , remove
I was reading of this and I find a lot of suggetions, use qtsoap,
I've not been able to find a whole lot on this anywhere. Let me
I've been googling a lot lately trying to find articles, books , or even
What is WSDL? i can't find a lot of references while googling... how can
I've have read a lot trying to find a way to cleanly consume lists
I have been trying since some days now to find a concrete answer for
On DBPedia you can find a lot of URIs that containing double underscores and
Auto-binding of request params seems like default behaviour, but I can't find a lot
I'm doing something like zgrep somepattern access_log.X.gz But I find that a lot of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.