0% found this document useful (0 votes)
394 views

08activity1 DataStructures&Algorithms Morales

The document describes creating an empty hash map in Java to store college degree program codes and names. It maps Bachelor of Science in IT, Computer Science, and Information Systems codes to their corresponding full names, then prints the keys, removes the first entry, and checks if a key exists.

Uploaded by

Hazzel Gilvero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
394 views

08activity1 DataStructures&Algorithms Morales

The document describes creating an empty hash map in Java to store college degree program codes and names. It maps Bachelor of Science in IT, Computer Science, and Information Systems codes to their corresponding full names, then prints the keys, removes the first entry, and checks if a key exists.

Uploaded by

Hazzel Gilvero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Name: Daren Cristian M.

Morales Date: 12/11/2021


08 Activity 1
Data Structures & Algorithm
1.Create an empty hash map named programs that will handle keys and values that are
both of String type.

Java Statement:
HashMap <String, String> programs = new HashMap <String, String>();

2.Map the following pairs:

a. BSIT – Bachelor of Science in Information Technology


Java Statement:
programs.put(“BSIT”, “Bachelor of Science in Information Technology”);
b. BSCS – Bachelor of Science in Computer Science
Java Statement:
programs.put(“BSCS”, “Bachelor of Science in Computer Science”);
c. BSIS – Bachelor of Science in Information Systems
Java Statement:
programs.put(“BSIS”, “Bachelor of Science in Information Systems”);

3.Display the keys in a single line.

Java Statement:
for (Map.Entry e : programs.emptySet()); {
System.out.println(e.getKey() + “: “ + e.getValue());
}
4.Delete the first entry.

Java Statement:
programs.remove(“BSIT”);
5.Check whether the map contains the key "BSCpE"
System.out.println(programs.containsKey(“BSCpE”);

You might also like