Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## interface Comparable and Comparator ##
- -----------
- ### interface Comparable ###
- Comparable : This interface has one method compareTo. Class whose objects to be sorted must implement this
- Comparable interface. In this case there is one form or way of sorting, e.g. We can sort players by age, so
- if we want to sort them by ranking or by name, in this case we have to change our Player class and change compareTo
- method to do that.
- -----------
- ### interface Comparator ###
- Comparator: This interface has two methods equals and compare. Class whose objects to be sorted do not need to
- implement this Comparator interface. Some third class can implement this interface to sort. In this case there are
- multiple forms of sorting, we can write different sorting based on different attributes of objects to be sorted, e.g.
- We can sort players by age, by ranking, and by namewithout change our Player class, to do that we use other class for
- Age Comparison and other class for Ranking Comparison and other class for Name Comparison.
- -----------
- ### The maximum size of array to allocate ###
- Some VMs reserve some header words in an array.
- Attempts to allocate larger arrays may result in
- OutOfMemoryError: Requested array size exceeds VM limit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement