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 8337357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:16:58+00:00 2026-06-09T04:16:58+00:00

Would this be a good idea? How can it be solved, if not, nowadays?

  • 0

Would this be a good idea? How can it be solved, if not, nowadays?

I think it would be interesting adding an

final boolean identical(Obj obj){
   return (this==obj);
}

so we had an improved equals (logical equals)

boolean equals (Obj obj){
   return identical(obj); // by default, but its overrideable
}

This question arised from the need in this other question (A Mechanism for having different equals (physical equals and logical equals) on objects in Collection) of having a way to compare a list of identical pointers to a list of equally objects. With that idea we could add to the Collection interface:

 coll.equals(coll2)
 coll.identical(coll2)
 coll.identicalElem(coll2){
      //current equals implementation of collections but calling identical to compare objects
 }

What do you think?

  • 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-06-09T04:16:59+00:00Added an answer on June 9, 2026 at 4:16 am

    The default equals() implementation you posted is already the one in java.lang.Object. There’s no real point in overriding it with the same implementation.

    Regarding your 3 methods to add to the collection interface:

    coll.equals(coll2): this one is already in the Collection interface.

    coll.identical(coll2): equivalent to coll == coll2, but less readable. I don’t see the point of such a method.

    coll.identicalElem(coll2): this method indeed doesn’t exist, but I’ve never had the need for such a method, so I think it should not clutter the API of Collection. You could use Guava’s Equivalence to do that:

    Equivalence.identity().pairWise().equivalent(coll1, coll2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty strong with SQL, but I can't think of good solution to this
Regardless of whether or not this is a good idea, is it possible to
Wondering what the best / good way of doing this would be in jQuery.
Before I throw something ugly together I thought this would be a good one
What's a good workaround to this IE bug that would still allow me to
Are there any good reasons for why you would include JavaScript like this: <script
Would this be a proper way to dispose of a BackGroundWorker? I'm not sure
I have this little text <div> Hello world<br> this is a good<br> text! <br><br>
Would this be the correct way of declaring that an XML element Cluster contains
Why would this work timeout 10s echo foo bar # foo bar but this

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.