HashMap of cats

  • 2
  • Locked
Here we've decided to make a collection of cats, so we're going to prepare a proper CATalog. In this program, someone has already gone to the trouble of writing a Cat class with a name field. Our task is to create a HashMap and add 10 cats to it. That's enough to start. As you probably already guessed, the cat's name should be used as the key.
You can't complete this task, because you're not signed in.
  • Popular
  • New
  • Old
You must be signed in to leave a comment
John SquirrelsLevel 41 , Richmond
14 June, 08:43
Extra theory on Maps can be found in these articles: HashMap: what kind of map is this? Map Interface and its implementations. Java HashMap, LinkedHashMap and TreeMap Examples This particular task can be completed by first creating an empty HashMap inside addCatsToMap(), then in a for each or a standard for loop iterating through the passed array of cats, adding each cat name from the array as a key and a new Cat() as a value to our newly created map. Lastly, return the map, which should now should be filled.
MartzehhLevel 9 , Ottawa
9 June, 18:15
Based on the lessons provided, in what world is this A: An easy question and B: properly explained? Real close to ditching my subscription. There are way too many of these poorly explained tasks.
Nickolas JohnsonLevel 8 , St. Louis
4 April, 16:37
OK so the explanation here is garbage so I'm going to drop a few hints. In a HashMap the KEY has to be unique NOT THE VALUE. Since you read in an array of unique values they can all act as the KEY and VALUE. That's what they seem to want even though they don't tell you the value should be the same as the key.
rajLevel 13 , Bhilai
12 March, 02:54
How toString method work ? After s.put(String,Cat) here how Cat return Name i can't understand
oli blaustromLevel 18 , Luzern
21 December 2019, 18:30
Extremely weird. Foreach loop works but normal for loop doesn't.
Fadi AlsaidiLevel 20 , Carrollton, TX
21 November 2019, 00:43
What happen when a new object gets created with a reference to a variable name? for example from the task above: I can say New Cat cat1 = new Cat("Simba") or I can instantiated a new Cat in the map value with our assigning it to cat1 . How is the world would i know how to pull any new cat and I dot have its referenced variable? like if I wanted to pull the new Cat "Simba", how would i go about doing that when i don't have the Cat object reference like cat1? I hope that makes sense
Param MLevel 8 , Mumbai
11 July 2019, 11:56
Guys i have no idea how to procede with the code and use the put function in the code
senthamil selvanLevel 20 , Eral
25 January 2019, 05:11
help plz
RomanLevel 41
25 January 2019, 06:56
Please create a question in the "Help" section.