Question
I need help in Java Programming Question: Write a declaration of a private field named Student that can hold an ArrayList. The elements of the
I need help in Java Programming Question:
Write a declaration of a private field named Student that can hold an ArrayList. The elements of the ArrayList are of type ComputerScience. Write an assignment to the student variable to create an appropriate ArrayListobjects.
Create a class MapTester and use HashMap to implement a phonebook
given below:
HashMapphoneBook = new HashMap ();
phoneBook.put("Homer Jay Simpson", "(531) 9392 4587"); phoneBook.put("Charles Montgomery Burns", "(531) 5432 1945"); phoneBook.put("ApuNahasapeemapetilon", "(531) 4234 4418");
I) In the HashMapclass,implement two methods :
public void enterNumber(String name, String number)and
public String lookupNumber(String name)
The methods should use the put and get methods of the HashMap class to implement
their functionality.
What happens when you add an entry to a map with a key that already exists in
the map?
What happens when you add an entry to a map with two different keys?
How do you check how many entries are contained in a map?
How do you print all the keys currently stored in a map?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started