Commonly asked Data Structures and Algorithms Problems by big tech and different solution approaches with code in Java and C

Powered by Blogger.

Wednesday, May 31, 2017

Comparable Java


Comparable is an interface in java which resides in java.lang package.
It has methode compareTo(Object o) to sort a List using Collections.Sort(listname);

Just implement class with Comparable  and write a function compareTo which returns 1 and -1 to sort accordingly.

0 Comments:

Post a Comment

Stats