InitialisingAttributes :
I have the following method that should return a product object if its name attribute matches the input string.
public Product find(String nameInput){
for(Product product : this.Products){
if(product.getName().equalsIgnoreCase(nameInput)){
return product;
}
}
}
Its giving me the following error:
I know that I could return null at the end of the method, however is there a more elegant way to do this?