Comparable and Comparator contract with regards to null
- by polygenelubricants
Comparable contract specifies that e.compareTo(null) must throw NullPointerException.
From the API:
Note that null is not an instance of any class, and e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false.
On the other hand, Comparator API mentions nothing about what needs to happen when comparing…