Removed unnecessary toString() 💀

This commit is contained in:
TiagoRG 2023-05-10 21:22:12 +01:00
parent 584582b08f
commit 78527f52d1
Signed by untrusted user who does not match committer: TiagoRG
GPG Key ID: DFCD48E3F420DB42
1 changed files with 2 additions and 15 deletions

View File

@ -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);
}
}