I need some help how to sort an ArrayList of objects. I have the superclass Account and two subclasses SavingsAccount and CreditAccount. Inside the Account class I have this method to call when I want to know the account number:
// Get account number
public String getAccountNumber() {
return accountNumber;
}
I need to sort the account numbers to get the highest number of all accounts in the objects?
The ArrayList is like this:
ArrayList<Account> accountList = new ArrayList<Account>();
Could this be done in a simple and not to comlicated way? Thanks!
You can use
sort
method inCollections
utility and your custom implementation ofComparator
interface.