• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in function remove in Set

 
Rikesh Desai
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source : Friends notes, not sure of the original source



The questions are in comments. Please help!
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look on the API of remove() method of the HashSet and the equals() method of the Integer class.
 
Rikesh Desai
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Abiraman for the pointer!



I added boolean conditions to test whether the elements are actually being removed or not.
And found that i2 here is not being removed!
how come??
then is it that i2 can now never be removed? i added new statements for remove and size and still the size is shown as 1.
Please help! I am getting confused..
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no value 47 in the set so why do you think the method should return true?
 
Rikesh Desai
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh! Now i get it!
thanks Wouter!
i was not thinking in the right direction!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic