« All Events
6 PM – Intro To Java
June 15, 2021 @ 6:00 pm - 7:00 pm
- We completed School Application.
- We learned about Map and HashMap where we can store key, value pairs. Map is useful to search things quickly.
- Homework:
- During the class, we created June15_HashMap.java.
- We created a HashMap variable called, “nameToPhoneMap”.
- Add some codes to do the following:
- Add the following name and phone number pairs to the “nameToPhoneMap” HashMap:
- “brian”, 888-888-8888
- “john”, 123-123-1234
- Add a forever loop, so you can keep asking user for a name and the program will provide a phone number if it exists inside “nameToPhoneMap”. We did a similar feature with “nameToAgeMap” in the class.
- Your program should look like this
-
Please enter a name: brian
BRIAN's phone number is 888-888-8888
Please enter a name: john
John's phone number is 123-123-1234
Please enter a name: exit
Thank you for using AYCLOGIC phone book.