Create an Integer value set in Java

Description

The following code shows how to create an Integer value set.

Example


//from  w ww. j  av a 2 s . c o m
import java.util.HashSet;

public class Main {
  public static void main(String[] args) {
    HashSet<Integer> hSet = new HashSet<Integer>();

    hSet.add(new Integer("1"));
    hSet.add(new Integer("2"));
    hSet.add(new Integer("3"));
    System.out.println("HashSet contains.." + hSet);

  }

}

The code above generates the following result.





















Home »
  Java Tutorial »
    Java Collection »




Java ArrayList
Java Collection
Java Comparable
Java Comparator
Java HashMap
Java HashSet
Java Iterator
Java LinkedHashMap
Java LinkedHashSet
Java LinkedList
Java List
Java ListIterator
Java Map
Queue
Java Set
Stack
Java TreeMap
TreeSet