Monday 1 June 2015

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]

No comments:

Post a Comment