We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Data Structures
- Java Comparator
- Discussions
Java Comparator
Java Comparator
Sort by
recency
|
265 Discussions
|
Please Login in order to post a comment
// import java.io.; import java.util.;
public class Solution {
}
import java.io.; import java.util.; import java.util.List; import java.util.ArrayList; class Student{ public String name; public int score; public Student(String name,int score){ this.name = name; this.score = score; }
} class Sortbyscore implements Comparator{ public int compare(Student a,Student b){ if(a.score == b.score){ return a.name.compareTo(b.name); } return b.score - a.score; } } public class Solution {
}