A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. Set also adds a stronger contract on the behavior of the equals and hashCode operations, allowing Set instances to be compared meaningfully even if their implementation types differ. Two Set instances are equal if they contain the same elements.

import java.io.*;
import java.util.List;
import java.util.*;// Arrays.sort
import java.util.ArrayList;
import java.util.Stack;
//import java.util.Queue.*;// Queue
public class Test_This {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
Process p1 = new Process();
class Process
String[] first = {"Java","A+","C#","XML","JSP","PHP","Z", "C#"};
public Process()
System.out.println("Default) constructor");
public void method_1()
//adding values to List collection
List<String> list = new ArrayList<String>();
TreeSet list1 = new TreeSet();
System.out.println("--adding arrays as heap in a collection----");
for(int i = 0; i < first.length; i++)
System.out.println("List " +list);
System.out.println("Tree List : " +list1);
System.out.print("Collection.min(list) :" + Collections.min(list));
System.out.print(" /Collections.max(list): " + Collections.max(list));
System.out.print("Collection.min(list1) :" + Collections.min(list1));
System.out.print(" /Collections.max(list1): " + Collections.max(list1));