File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change 11
22class Person implements Comparable <Person >{
3- int start ,end ,c ;
4- public Person (int start ,int end ,int c ){
5- this .start =start ;
6- this .end =end ;
7- this .c =c ;
8- }
3+ private int start , end , salary ;
94
10- public int compareTo (Person p ){
11- return this .start - p .start ;
5+ public Person (int start , int end , int salary ){
6+ this .start = start ;
7+ this .end = end ;
8+ this .salary = salary ;
9+ }
10+
11+ @ Override
12+ public int compareTo (Person that ){
13+ return this .start - that .start ;
1214 }
1315}
Original file line number Diff line number Diff line change @@ -15,9 +15,9 @@ public int getAge(){
1515
1616public class ComparatorSnippet {
1717
18- public static void main (String ... s ) {
18+ public static void main (String ... args ) throws Exception {
1919
20- Developer [] devs = Collections .sort (listDevs , new Comparator <Developer >() {
20+ Developer [] devs = Collections .sort (listDevs , new Comparator <Developer >() {
2121 @ Override
2222 public int compare (Developer o1 , Developer o2 ) {
2323 return o1 .getAge () - o2 .getAge ();
You can’t perform that action at this time.
0 commit comments