1 |
|
/* |
2 |
|
* Written by Martin Buchholz with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
/* |
26 |
|
public class NoNulls { |
27 |
|
void test(String[] args) throws Throwable { |
28 |
|
final Comparator<String> nullTolerantComparator |
29 |
< |
= new Comparator<>() { |
29 |
> |
= new Comparator<String>() { |
30 |
|
public int compare(String x, String y) { |
31 |
|
return (x == null ? -1 : |
32 |
|
y == null ? 1 : |
34 |
|
}}; |
35 |
|
|
36 |
|
final SortedSet<String> nullSortedSet |
37 |
< |
= new TreeSet<>(nullTolerantComparator); |
37 |
> |
= new TreeSet<String>(nullTolerantComparator); |
38 |
|
nullSortedSet.add(null); |
39 |
|
|
40 |
|
final PriorityQueue<String> nullPriorityQueue |
41 |
< |
= new PriorityQueue<>() { |
41 |
> |
= new PriorityQueue<String>() { |
42 |
|
public Object[] toArray() { return new Object[] { null };}}; |
43 |
|
|
44 |
< |
final Collection<String> nullCollection = new ArrayList<>(); |
44 |
> |
final Collection<String> nullCollection = new ArrayList<String>(); |
45 |
|
nullCollection.add(null); |
46 |
|
|
47 |
|
THROWS(NullPointerException.class, |