0% found this document useful (0 votes)
77 views6 pages

Experiment - 2.1: (For Applied/experimental Sciences/materials Based Labs)

The document summarizes an experiment conducted by a student to create programs demonstrating the use of hash tables and sets in Java. The experiment had two parts: 1) Creating a program to view keys from a hash table by using a keySet and iterator. 2) Creating a program showing usage of the Set collection interface by adding strings to a HashSet. The output of both programs is presented. The student learned about creating programs with hash tables and sets in Java as well as related functions and syntax.

Uploaded by

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

Experiment - 2.1: (For Applied/experimental Sciences/materials Based Labs)

The document summarizes an experiment conducted by a student to create programs demonstrating the use of hash tables and sets in Java. The experiment had two parts: 1) Creating a program to view keys from a hash table by using a keySet and iterator. 2) Creating a program showing usage of the Set collection interface by adding strings to a HashSet. The output of both programs is presented. The student learned about creating programs with hash tables and sets in Java as well as related functions and syntax.

Uploaded by

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

Experiment -2.

Student Name: - Shinde Smita Shahaji UID:-20BCS4643

Branch: - (CSE_IOT) Section/Group: - 20BIT (B)

Semester: - 4th Date of Performance: - 03/28/2022

Subject Name: -Project Based Learning in Java Lab Subject Code: - 20CSP-287

1. Aim/Overview of the practical:

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

(b) Create a program to show the usage of Sets of Collection interface.

2. Task 2. Task to be done:

To create a program to set view of Keys from Java Hash table and to show the
usage of Sets of Collection interface.
3. Apparatus (For applied/experimental sciences/materials based labs):

PC with installed JDK and IDE (Eclipse or Intelli J)


4. Steps for experiment/practical:

Code A-

package smita;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
public class Hash_part_A
{
public static void main(String[] args)
{
Hashtable ht = new Hashtable();
ht.put("KEY > 1", "ONE");
ht.put("KEY > 2", "TWO");
ht.put("KEY > 3", "THREE");
System.out.println("SMITA SHINDE UID = 20BCS4643\n");
Set st = ht.keySet();
System.out.println("<--- KEYS IN THE SET CREATED FROM HASHTABLE ARE --->");
Iterator itr = st.iterator();
while (itr.hasNext())
System.out.println(itr.next());
st.remove("KEY > 1");
System.out.println("<--- HASHTABLE KEYS AFTER REMOVAL FROM SET ARE --->");
Enumeration e = ht.keys();
while (e.hasMoreElements())
System.out.println(e.nextElement());
}
}
Code B-

package smita;

import java.util.*;
public class Hash_part_B
{
public static void main(String[] args)
{
System.out.println("== PROGRAM FOR USAGE OF SETS OF COLLECTION INTERFACE
==");
System.out.println("SMITA SHINDE UID = 20BCS4643\n");
Set<String> h1_HashSet = new HashSet<String>();
h1_HashSet.add("HeLLo");
h1_HashSet.add("Class!");
h1_HashSet.add("I am smita !");
h1_HashSet.add("Working on Usage of Sets of Collection Interface");
System.out.println("printing the collection of interface \n" +h1_HashSet);
}
}
5. Result/Output/Writing Summary:

Output part A-
Output part B
Learning outcomes (What I have learnt):

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


2. Created a program to show the usage of Sets of Collection interface
3. Syntax and implementation of respective functions and keyword used in this
program.
4. Implementation of Collection Set of Interfaces in Java
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):

Sr. No. Parameters Marks Obtained Maximum Marks


1.
2.
3.

You might also like