Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equal method on collection

 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why above code is not throwing assertion error at line 1?
Thanks
Barkat
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm... good question. I do not know the answer, but I'd like to add one more thing:
If you don't override equals, two objects are considered equals if they referred to the same object.
probably it does not have anything to do with the question itself.
any other opinions?
[ July 24, 2003: Message edited by: Andres Gonzalez ]
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did little research on it. The equals method of LinkedList class will apply. And it is overridden. Per it's definition if two collections have same elements in same order, they considered same or in other words equal.
Hope this helps.
Barkat
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Barkat Mardhani:
I did little research on it. The equals method of LinkedList class will apply. And it is overridden. Per it's definition if two collections have same elements in same order, they considered same or in other words equal.
Hope this helps.
Barkat


Thanks Barkat. I wonder if the overriding of equals is also done for all collection classes, besides LinkedList (according to you).
[ July 24, 2003: Message edited by: Andres Gonzalez ]
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Barkat. I wonder if the overriding of equals is also done for all collection classes, besides LinkedList (according to you).

I checked couple more. Seems they overridden either in Abstractxxxx class or concrete class.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic