I have an arrayList and I want to search for a specific item and perform an action on it like so:
System.out.print("What is the ID of the shop that you want to delete?");
int removedShopID= Integer.parseInt(in.next());
for(int i=0; i<shops.size(); i++){
if(shops.get(i).getID()==removedShopID)
{ shops.remove(i);
System.out.println("The shop has been successfully deleted.");}
}
}
It is working fine but I need to add a statement in case of no ID matched it will print " not found" or something. any help?