| Author |
Question About TreeSet?
|
Afzal Rehman
Ranch Hand
Joined: Dec 16, 2009
Posts: 35
|
|
Why Output is 1? ,
|
SCJP 6.0
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 13408
|
|
First, you example uses a HashSet -- not a TreeSet.... To answer your question, Sets don't allow duplicates.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Brij Garg
Ranch Hand
Joined: Apr 29, 2008
Posts: 234
|
|
|
Add method will return false if the object it is adding to the set is already there in the set.
|
 |
bhanu chowdary
Ranch Hand
Joined: Mar 09, 2010
Posts: 256
|
|
|
HashSet won't allow duplicates.
|
 |
 |
|
|
subject: Question About TreeSet?
|
|
|