undefined

Practice with collections

Java Syntax
Level 8 , Lesson 3
Available

"Hi, Amigo. I'd like to give you a couple of tasks about collections:"

undefined
2
Task
Java Syntax, level 8, lesson 3
Locked
HashSet of plants
It's time to gather in the harvest. Let's create a HashSet with String elements. And here are the ten strings that we'll add to it: watermelon, banana, cherry, pear, cantaloupe, blackberry, ginseng, strawberry, iris, potato. Then we'll display the contents of the collection, and observe the order of the collection entries.
undefined
2
Task
Java Syntax, level 8, lesson 3
Locked
HashMap of 10 pairs
In the lessons, your mentors explained that a Map is a set of key-value pairs, where the key is a unique name that can be used to access a value. We're going to start working with the HashMap collection. Let's create an instance of this type of collection and tell people about plants. For example: value — fruit, key — watermelon.
undefined
2
Task
Java Syntax, level 8, lesson 3
Locked
HashMap of cats
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.
undefined
2
Task
Java Syntax, level 8, lesson 3
Locked
Display a list of keys
Hideouts, passwords, keys! The captured secret agent will have to disclose it all without holding anything back… Actually, no. The keys and passwords will be enough. Her captors managed to recover a small program with a HashMap containing ten strings. Your task is to display a list of keys, printing each element on a new line.
undefined
2
Task
Java Syntax, level 8, lesson 3
Locked
Values on the screen!
A secret agent has been ambushed. To prevent the information she was carrying from vanishing, she needs to launch an application on her laptop. In this application, she found and created a HashMap containing 10 strings. Help the secret agent display the values on the screen, printing each element on a new line.
undefined
2
Task
Java Syntax, level 8, lesson 3
Locked
HashMap of Objects
Working with collections requires skill and professionalism. This is the same reason we don't let total noobies shoot a gun. But here on the eighth level, it's time to start digging into them. Suppose we have a HashMap, and 10 different object pairs have been added. Your task is to display the contents of the collection.
Comments (48)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
SHAAHEEN Level 10 Gothenburg Sweden
24 March 2021
practice makes perfect
ashley819 Level 9 Washington DC United States
25 June 2020
He always says, "a couple of tasks." I don't think that means what he thinks it means...
Oliver Heintz Level 18 Mustang United States
17 June 2020
What is the difference between using

Set<String> set = new HashSet<String>();
and

HashSet<String> set = new HashSet<String>();
Oliver Heintz Level 18 Mustang United States
17 June 2020
It is costing more and more dark matter to unlock lessons. Are we going to ever run into a situation where we've completed the tasks we've been given, but we don't have the dark matter to keep going?
Rod Johnston Level 13 Melbourne Australia
15 June 2020
For the HashSet of plants, don't declare and initialise the HashSet variable as described on the previous page, like this: Set <String> plants = new HashSet<String>(); This won't pass validation. You need to declare the variable as a HashSet: HashSet<String> plants = new HashSet<String>(); It's a pity the validation and lesson don't agree.
BlueJavaBanana Level 37
15 April 2020
https://www.youtube.com/watch?v=KyUTuwz_b7Q Absolutley amazing video on hash tables and has functions.
Ted404 Level 11 Dubai United Arab Emirates
3 April 2020
I actually did get much from the previous lessons about HashMaps and in general, about collections. Is this normal? we cannot figure out how to create a simple HashMap without checking the other sources.
9 March 2020
For those who got stuck: You will be returning name of the cat & name of the cat in upper case (x10). This is one of the few times that it is really difficult to understand what is being asked of you. Good luck!
Austeja Level 10 Kaunas Lithuania
13 February 2020
Not that easy as labeled;/ :D
ashgolan Level 8 Ashdod Israel
13 November 2019
moving on. :)