I have a map with strings, I want to transform it to a list of strings with \" \" as a key value separator. Is it possible using google collections?
Code example that I
Here's a functional approach using Java 8 streams:
List kv = map.entrySet().stream()
.map(e -> e.getKey() + " " + e.getValue()) //or String.format if you prefer
.collect(Collectors.toList());
If you're not wedded to the functional style, here's a more concise variant of the obvious for loop:
List kv = new ArrayList<>();
map.forEach((k, v) -> kv.add(k + " " + v));