Lets say i’ve a Album class. How do i code the compareTo method so that when i’ve a ArrayList of Album object and i call
Collections.sort()
it will sort them in by title follow by singer in ascending order.
Public class Album implements Comparable{
private String title;
private String singer;
private double price;
.....
public int compareTo(){
// How to
}
}
1 Answer