in my code i have created an array:
static BankClient clients[] = new BankClient[MAXCLIENTS]; // This array holds the clients up to a max of 1000
what i need to do is check this array to see if it contains a specific int. i was able to do this successfully through the use of a for loop and an if statement as shown below:
System.out.println("\n Ask for ID");
System.out.println(">");
IDInput = input.nextInt();
System.out.println("Check ID \n");
for (int i = 0; i < clients.length; i++)
{
BankClient managementOptions = clients[i];
if (managementOptions.getID() == IDInput)
{
// code in here
}
however, once i tried to put an else statement at the bottom to write an error message to the user, as a result of an invalid id, it proceed to print out an error for all ids saved in the array that do not match the id given by the user. this is what i wanted:
else if (// check if IDInput doesnt exist within the client array)
{
System.out.println("Error. Client does not exist.");
}
however i cant seem to figure out what to put between the brackets. any help would be super appreciated! still pretty new to this website so if you need anymore information i will try my best to add it.