Copy all elements of Java LinkedHashSet to an Object Array : LinkedHashMap « Collections Data Structure « Java






Copy all elements of Java LinkedHashSet to an Object Array


import java.util.LinkedHashSet;

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

    lhashSet.add(new Integer("1"));
    lhashSet.add(new Integer("2"));
    lhashSet.add(new Integer("3"));

    Object[] objArray = lhashSet.toArray();

    for (Object inte: objArray){
      System.out.println(inte);
    }
  }
}

 








Related examples in the same category

1.Check if a particular key exists in Java LinkedHashMap example
2.Check if a particular value exists in Java LinkedHashMap example
3.Get Set view of Keys from Java LinkedHashMap
4.Get Size of Java LinkedHashMap
5.Iterate through the values of Java LinkedHashMap
6.Remove all values from Java LinkedHashMap
7.Remove value from Java LinkedHashMap
8.Simple Java LinkedHashMap
9.Check if a particular element exists in Java LinkedHashSet
10.Implementing a Least-Recently-Used (LRU) Cache