| Author |
How is order working in a Collection?
|
Joey Sanchez
Ranch Hand
Joined: Jun 23, 2011
Posts: 70
|
|
This class is ordered by name but what does it happen when various objects have the same name?
Result:
Which object is the first? Depends on value, hashcode..?
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26144
|
|
|
It depends on the original order of the list which affects the order compare to is run. In other words, you shouldn't rely on the order. It isn't guaranteed and future implementations of the JDK could change it.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: How is order working in a Collection?
|
|
|