I love Guava, and I'll continue to use Guava a lot. But, where it makes sense, I try to use the "new stuff" in Java 8 instead.
"Problem"
Lets say I want to join url attributes in a String
. In Guava I would do it like this:
Map<String, String> attributes = new HashMap<>();
attributes.put("a", "1");
attributes.put("b", "2");
attributes.put("c", "3");
// Guava way
String result = Joiner.on("&").withKeyValueSeparator("=").join(attributes);
Where the result
is a=1&b=2&c=3
.
Question
What is the most elegant way to do this in Java 8 (without any 3rd party libraries)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…