cs notebook0
  • Introduction
  • Core Java
  • some notes
  • Data structure&algorithm
  • Garbage Collection
  • HashMap
  • Collection0
  • Collection1
  • Collection2
  • comparatorVScomparable
  • exception0
  • exception1
  • exception2
  • Enum in Java
  • JVM
  • Wrapper Classes in Java
  • String, int convert
  • HashSetVSTreeSetVSLinkedHashSet
  • Pair
Powered by GitBook
On this page
  • 1 Comparable interface
  • 1.1 Comparable interface has compareTo(T obj) method to be override
  • 2 Comparator interface
  • 2.1 Comparator interface compare(Object o1, Object o2) method need to be implemented.

Was this helpful?

comparatorVScomparable

1 Comparable interface

1.1 Comparable interface has compareTo(T obj) method to be override

can sort based on one field only and we can't chose the field on which we want to sort object.##

2 Comparator interface

2.1 Comparator interface compare(Object o1, Object o2) method need to be implemented.

PreviousCollection2Nextexception0

Last updated 6 years ago

Was this helpful?