I am trying to print the
TreeMap<String, TreeSet<String>> abbreviations
in Java
I tried:
if (abbreviations.size() > 0)
abbreviations.forEach((x, y) -> {
System.out.println(String.format("%-7s : %-100s ", x, y));
});
It printing like this:
US : [ Unity Status, Unresolved Sample]
VC : [ Value Color, Value Contex, Value Context, Video Conference, Visibility Created, Visit Created, Visits Completed]
But I like to print without square brackets.
US : Unity Status, Unresolved Sample
VC : Value Color, Value Contex, Value Context, Video Conference, Visibility Created, Visit Created, Visits Completed
What can I try next?
有很多方法可以做到这一点,其中之一是像这样使用String.join
:
String.format("%-7s : %-100s ", x, String.join(", ", y))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.