Notes
Notes - notes.io |
/**
*
* Topic : Java Collections
*
* Instructions :
* 1. Activity to implement Map collection of Java Collections Framework
* 2. Code as per the TODOs
*
*/
import java.util.*;
public class MapActivityClass_Participant {
/**
* Type code to create a HashMap of key value pairs<br/>
* where key is id of type String and value is a name
* @param args
*/
{
System.out.println("List of available events are as below:");
}
Map<String, String> map = new HashMap <>();{
map.put("E_001","HIGH RIDE");
map.put("E_002","LOW RIDE");
map.put("E_003","ZOO");
System.out.println(map.get("E_001"));
System.out.println(map.get("E_002"));
System.out.println(map.get("E_003"));
Collection<String> setOfKeys =map.keySet();
Set<String> values =(Set<String>) map.values();
System.out.println("List of available events are below:" +setOfKeys +values);
}
// TODO 2 Create a Map<String, String> object using HashMap constructor
// TODO 3 Populate the map with below values using the put() method.
// Event ID Event Name
// ==============================
// E_001 HIGH RIDE
// E_002 LOW RIDE
// E_003 ZOO
// TODO 4 Print the values in console associated with the map key using the get() method.
// TODO 5 Create a Set<String> object that contains all the map keys retrieved using the keySet() method.
// TODO 6 Create a Collection<String> object that contains all the key values retrieved using the values() method.
// TODO 7 Print the statement in console "List of available events are as below:" before printing the map details.
// TODO 8 Print all the map key collected in Set<String>.
// TODO 9 Print all the map values collected in Collection<String>.
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team