Removed unnecessary toString() 💀
This commit is contained in:
parent
584582b08f
commit
78527f52d1
|
@ -8,20 +8,7 @@ import java.util.*;
|
||||||
|
|
||||||
public class WordPairCounter {
|
public class WordPairCounter {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TreeMap<String, HashMap<String, Integer>> wordPairs = new TreeMap<>() {
|
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();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
String text = "";
|
String text = "";
|
||||||
Path path = Paths.get((new Scanner(System.in)).nextLine());
|
Path path = Paths.get((new Scanner(System.in)).nextLine());
|
||||||
|
@ -42,6 +29,6 @@ public class WordPairCounter {
|
||||||
word1Pair.put(word2, word1Pair.getOrDefault(word2, 0) + 1);
|
word1Pair.put(word2, word1Pair.getOrDefault(word2, 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(wordPairs);
|
wordPairs.entrySet().forEach(System.out::println);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue