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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!