LinkedHashSet - adding elements order is maintained







LinkedHashSet - LinkedHashSet maintains insertion order.




import java.util.LinkedHashSet;
import java.util.Set;
public class linkedHashSetBlog {
   public static void main(String args[]) {
          Set<String> linkedHashSet = new LinkedHashSet<String>();
          linkedHashSet.add("javaMadeSoEasy");
          linkedHashSet.add("ankit");
          linkedHashSet.add("mittal");
          System.out.println("linkedHashSet = "+linkedHashSet);
   }
}
/*OUTPUT
linkedHashSet = [javaMadeSoEasy, ankit, mittal]
*/


RELATED LINKS>


No comments:

Post a Comment