what iis linkedhashset code example
Example: LinkedHashSet in java
import java.util.LinkedHashSet;
public class LinkedHashsetExample
{
public static void main(String[] args)
{
LinkedHashSet<String> lhs = new LinkedHashSet<String>();
lhs.add("Anteater");
lhs.add("Bear");
lhs.add("Cheetah");
lhs.add("Deer");
lhs.add("Anteater");
lhs.add("Elephant");
System.out.println("LinkedHashSet size: " + lhs.size());
System.out.println("Given LinkedHashSet: " + lhs);
System.out.println("Deer removed from LinkedHashSet: " + lhs.remove("Deer"));
System.out.println("Remove Zebra which is not present: " + lhs.remove("Zebra"));
System.out.println("Check if Anteater is present: " + lhs.contains("Anteater"));
System.out.println("New LinkedHashSet: " + lhs);
}
}