+++ /dev/null
-import java.util.Comparator;
-
-class IStrComparator implements Comparator<String> {
- private String wordToCompare;
-
- IStrComparator(String w) {
- wordToCompare = w;
- }
-
- public int compare(String str1, String str2) {
- return str1.compareTo(str2);
- }
-
-}
import java.util.Scanner;
import java.io.IOException;
import java.util.TreeMap;
+import java.util.SortedMap;
class Main {
catch (IOException e) {
e.printStackTrace();
}
+
+ System.out.println("TreeMap full content:");
for (String wordCursor : tm.keySet()) {
System.out.println("Word \"" + wordCursor + "\" occured " + tm.get(wordCursor) + " times");
}
+
+ System.out.println("SortedMap content after the word \"milieu\":");
+ SortedMap<String, Integer> stm = tm.tailMap("milieu");
+ for (String wordCursor : stm.keySet()) {
+ System.out.println("Word \"" + wordCursor + "\" occured " + stm.get(wordCursor) + " times");
+ }
}
}