public class BankAccount { . . . public int compareTo(Object otherObject) { BankAccount other = (BankAccount)otherObject; if (balance < other.balance) return -1; if (balance == other.balance return 0; return 1; } . . . }