You are on page 1of 2

Experiment – 2.

Student Name: Vivek UID: 20BCG1024


Branch: CSE, G&G Section/Group: 20BCG1, A
Semester: 4th Date of Performance:17-03-2022
Subject Name: Project Based Java lab Subject Code: 20CSP-287

1. Aim/Overview of the practical:


Create a program to set view of Keys from Java Hash table.

2.Apparatus: Java Eclipse

3.Algorithm:
For Java hashtable
1. Import enumeration and hashtable libraries.
2. Create object of hashtable and use put function to insert the element in the table.
3. Create object of enumeration and use while loop to iterate the elements.

4.Code:
import java.util.Enumeration;
import java.util.Hashtable;
public class Main {
public static void main(String[] args)
{
Hashtable ht = new Hashtable();
ht.put("1", "One");
ht.put("2", "Two");
ht.put("3", "Three");
Enumeration e = ht.keys();
while (e.hasMoreElements())
{
System.out.println(e.nextElement());

}
}

5.Output:

6.Learning outcomes (What I have learnt):


Hashtable and enumeration in Java.

Evaluation Grid (To be created as per the SOP and Assessment guidelines by the
faculty):

You might also like