Check if a particular element exists in LinkedHashSet in Java
Description
The following code shows how to check if a particular element exists in LinkedHashSet.
Example
/*from w ww . j ava2s . c o m*/
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"));
System.out.println(lhashSet.contains(new Integer("3")));
}
}
The code above generates the following result.