jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes equal method on collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "equal method on collection" Watch "equal method on collection" New topic
Author

equal method on collection

Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787

Why above code is not throwing assertion error at line 1?
Thanks
Barkat
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
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 ]

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
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

Joined: Nov 27, 2001
Posts: 1561
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

Joined: Aug 05, 2002
Posts: 787

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: equal method on collection