The following Comparator class is attempting to arrange BankAccount objects by account name, breaking ties by account

Question:

The following Comparator class is attempting to arrange BankAccount objects by account name, breaking ties by account balance. But the code has some syntax errors and some logic errors. What is wrong with the code? How would you correct it?

1 import java.util.*; 2 public class AccountComparator extends Comparator { 3. public int compareTo (BankAccount account2) { if (!this.getName ().equals (account2.getName () )) { 4 return this.getName ().compareTo (account2.getName ()); } else { return this.getBalance () account2.getBalance (); 8. 9. 10 }

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: