Accounting Basics Tutorial

Java Collections Set

Set Interface

A Set is a Collection that cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.
We can add and remove the data from the HashSet and treeset data.

import java.util.*;

public class SetDemo {

  public static void main(String args[]) {
     int count[] = {34, 22,10,60,30,22};
     Set<Integer> set = new HashSet<Integer>();
        for(int i = 0; i<5; i++){
        TreeSet sortedSet = new TreeSet<Integer>(set);
        System.out.println("The sorted list is:");

        System.out.println("The First element of the set is: "+
        System.out.println("The last element of the set is: "+
     catch(Exception e){}

google ads place