0% found this document useful (0 votes)
44 views1 page

Hash Set

This Java code creates a TreeSet to store String elements in alphabetical order. It adds the elements "Beta", "Alpha", "Eta", "Gamma", "Epsilon", and "Omega" to the TreeSet and then prints out the sorted set.

Uploaded by

Treymax Sikan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views1 page

Hash Set

This Java code creates a TreeSet to store String elements in alphabetical order. It adds the elements "Beta", "Alpha", "Eta", "Gamma", "Epsilon", and "Omega" to the TreeSet and then prints out the sorted set.

Uploaded by

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

// Demonstrate HashSet.

import java.util.*;
class HashSetDemo {
public static void main(String args[])
{
// Create a hash set.
//HashSet<String> hs = new
HashSet<String>();
TreeSet<String> hs = new
TreeSet<String>();
// Add elements to the hash set.
hs.add("Beta");
hs.add("Alpha");
hs.add("Eta");
hs.add("Gamma");
hs.add("Epsilon");
hs.add("Omega");
System.out.println(hs);
}
}

You might also like