Set of cats

  • 10
  • unavailable
You need to create a set of cats. This requires a public static Cat class. Then implement the createCats method, which should create a Set of cats and add 3 cats to it. In the main method, remove one cat from Set cats. Finally, implement the printCats method. It should display all the cats that remain in the set.
You can't complete this task, because you're not signed in.
Comments(5)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Miha ČelešnikLevel 9 , Ilirska Bistrica
20 November, 23:12
Same here. Tnx
Kavita RaoLevel 13 , Rockville
4 October, 22:32
Thanks Turner, I too had a name to distinguish the objects and toString method. After removing these, the task passed.
TurnerLevel 11 , Pittsburgh
1 September, 17:31
As mentioned below the hardest part in solving this problem is doing the random access remove using an Iterator. However, the trick into meeting all the other requirements is CODE only what is asked of you. :). I was unable to get the verification to pass until I removed the name and age I had put in my Cat class. I had an overridden toString() and nice formatting of each of my Cat objects printed in my printedCats method, etc. Verification wasn't having none of it. LOL.
JaisinghLevel 13 , Hyderabad
1 October 2018, 14:25
how do i remove an object from the set . i have tried many ways but got nothing. most of the time it says cannot find the symbol not find. "used set.remove method()" but confused with what argument needed to send there so i can remove that element in the set. plz do help me...!!
Ankush RajputLevel 25 , Bhopal
1 October 2018, 14:50
Since set does not guarantee order, you cannot access its elements like an array or arraylist. You'll have to use iterator to access elements of set and remove them. A simple google search will lead you to this - https://stackoverflow.com/questions/28178554/remove-element-from-set