64 |
|
} |
65 |
|
|
66 |
|
private static final Comparator<String> NULL_AT_END |
67 |
< |
= new Comparator<String>() { |
67 |
> |
= new Comparator<>() { |
68 |
|
/** |
69 |
|
* Allows for nulls. Null is greater than anything non-null. |
70 |
|
*/ |
78 |
|
|
79 |
|
public static void main(String[] args) { |
80 |
|
try { |
81 |
< |
SortedMap<String,String> m1 |
82 |
< |
= new TreeMap<String,String>(NULL_AT_END); |
81 |
> |
SortedMap<String,String> m1 = new TreeMap<>(NULL_AT_END); |
82 |
|
check(eq(m1.put("a", "a"), null)); |
83 |
|
check(eq(m1.put("b", "b"), null)); |
84 |
|
check(eq(m1.put("c", "c"), null)); |
85 |
|
check(eq(m1.put(null, "d"), null)); |
86 |
|
|
87 |
< |
SortedMap<String,String> m2 = new TreeMap<String,String>(m1); |
87 |
> |
SortedMap<String,String> m2 = new TreeMap<>(m1); |
88 |
|
|
89 |
|
check(eq(m1.lastKey(), null)); |
90 |
|
check(eq(m1.get(m1.lastKey()), "d")); |