public class Tester { public static void main(String[]args) { ArrayList<BankAccount> balance = new ArrayList<BankAccount>(); balance.add(new BankAccount(1000)); balance.add(new BankAccount(1500)); balance.add(new BankAccount(750)); balance.add(new BankAccount(2350)); balance.add(new BankAccount(525)); Collections.sort(balance); // this is the error line } public interface Comparable <BankAccount> { int compareTo(Object other); }
Can anyone tell me what the problem is?public class BankAccount implements Comparable <BankAccount> { ..... etc }
Description
Bound mismatch: The generic method sort(List<T>) of type Collections is not applicable for the arguments (ArrayList<BankAccount>). The inferred type BankAccount is not a valid substitute for the bounded parameter <T extends Comparable<? super T>>line 44 Java Problem
Thanks.