Hello there! I've created a method that searches for the customer with the highest deposit. Here's what I have so far:
public Customer searchHighestDeposit(ArrayList<Customer> customers){
for(int i=0; i<customers.size();i++)
if(customers.get(i).getBankAccount().getBalance()>customers.get(i+1).getBankAccount().getBalance())
return customers.get(i);
else
return customers.get(i+1);
return null;
The output is kinda weird: "The customer with the highest deposit is: bank.Customer@c390508"
The answer is supposed to be Richard.
I'm calling the method from main:
System.out.println("The customer with the highest deposit is: "+bank.searchHighestDeposit(customers));