You can create a new class that inherits from HashSet:

Set<String> h = new HashSet<String>() {{
    add("a");
    add("b");
}};

One line solution:

Set<String> h = new HashSet<String>(Arrays.asList("a", "b"));

Using guava:

Sets.newHashSet("a", "b", "c")

Using Streams:

Set<String> set3 = Stream.of("a", "b", "c").collect(toSet());