how do if fix the Exception in thread "main" java.lang.NullPointerException at BankSystem.Branches.findCustomer(Branches.java:44) I'm new to coding and java is my first language and I keep getting this error I don't know to fix it.
package BankSystem;
import java.util.ArrayList;
public class Branches {
private String name;
private ArrayList<Customers> newCustomer;
public Branches(){
}
public Branches(String name) {
this.name = name;
this.newCustomer = new ArrayList<>();
}
public ArrayList<Customers> getNewCustomer(){
return newCustomer;
}
public String getName() {
return name;
}
public boolean addCustomer(String name, double amount) {
if (findCustomer(name) == null) {
this.newCustomer.add(new Customers(name, amount));
return true;
}
return false;
}
public boolean addTranstraction(String name, Double amount) {
Customers existingCustomer = findCustomer(name);
if (existingCustomer != null) {
existingCustomer.addTransactions(amount);
return true;
}
return false;
}
private Customers findCustomer(String name) {
for(int i=0; i<this.newCustomer.size(); i++){
Customers checkedCustomer = this.newCustomer.get(i);
if(checkedCustomer.getName().equals(name)) {
return checkedCustomer;
}
}
return null;
}
}