How to Create LinkedHashSet In Java

import java.util.LinkedHashSet;
import java.util.Set;

public class CreateLinkedHashSet {

public static void main(String[] args) {

Set<String> lhs = new LinkedHashSet<String>();

lhs.add(“mumbai”);
lhs.add(“delhi”);
lhs.add(“kolkata”);
lhs.add(“chandigarh”);
lhs.add(“dehradun”);

//print linkedhashset
System.out.println(“lhs is = “+lhs);

}

}

Output:

lhs is = [mumbai, delhi, kolkata, chandigarh, dehradun]

Leave a Reply

Your email address will not be published. Required fields are marked *

4 + 6 =