Java examples for Collection Framework:LinkedHashSet
How to iterate through elements LinkedHashSet object.
import java.util.LinkedHashSet; import java.util.Iterator; public class Main { public static void main(String[] args) { LinkedHashSet lhashSet = new LinkedHashSet(); // ww w. j a v a 2 s. co m //add elements to LinkedHashSet object lhashSet.add(new Integer("1")); lhashSet.add(new Integer("2")); lhashSet.add(new Integer("3")); Iterator itr = lhashSet.iterator(); System.out.println("LinkedHashSet contains : "); while(itr.hasNext()) System.out.println(itr.next()); } }