Currently, this is what I've tried:
System.out.println(treeMap.toString());
However, that prints the contents of the tree as:
{A=1, AND=1, BE=1, BY=2...}
How could I print the entire tree to be shown as below?
A=1
AND=1
BE=1
BY=2
Try this:
treeMap.forEach((k,v) -> System.out.println(k + "=" + v + "\n"));
Map<String, Integer> map = new TreeMap<>(); map.put("A", 1); map.put("B", 2); map.entrySet().forEach(System.out::println);