Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to add a singleton hashset in java

// With Class Type
Set<String> set = new HashSet<>(Arrays.asList("a", "b", "c"));
//Anonymous Class
Set<String> set = new HashSet<String>(){{
    add("a");
    add("b");
    add("c");
}};
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #add #singleton #hashset #java
ADD COMMENT
Topic
Name
9+4 =