Removed unnecessary toString() 💀
This commit is contained in:
parent
a9944f06f7
commit
71c1e01cc6
|
@ -8,20 +8,7 @@ import java.util.*;
|
|||
|
||||
public class WordPairCounter {
|
||||
public static void main(String[] args) {
|
||||
TreeMap<String, HashMap<String, Integer>> wordPairs = new TreeMap<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String word1 : this.keySet()) {
|
||||
sb.append(word1).append("={");
|
||||
for (String word2 : this.get(word1).keySet()) {
|
||||
sb.append(word2).append("=").append(this.get(word1).get(word2)).append(", ");
|
||||
}
|
||||
sb.delete(sb.length()-2, sb.length()).append("}\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
};
|
||||
TreeMap<String, HashMap<String, Integer>> wordPairs = new TreeMap<>();
|
||||
|
||||
String text = "";
|
||||
Path path = Paths.get((new Scanner(System.in)).nextLine());
|
||||
|
@ -42,6 +29,6 @@ public class WordPairCounter {
|
|||
word1Pair.put(word2, word1Pair.getOrDefault(word2, 0) + 1);
|
||||
}
|
||||
|
||||
System.out.println(wordPairs);
|
||||
wordPairs.entrySet().forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue