here is no such thing for HashMaps, but you can create an ImmutableMap with a builder:
final Map<String, Integer> m = ImmutableMap.<String, Integer>builder(). put("a", 1). put("b", 2). build();
And if you need a mutable map, you can just feed that to the HashMap constructor.
final Map<String, Integer> m = Maps.newHashMap( ImmutableMap.<String, Integer>builder(). put("a", 1). put("b", 2). build());
Read full article from java - builder for HashMap - Stack Overflow
No comments:
Post a Comment