wont display selected array
When im searching for a particle name details in an array it keeps displaying the all details in it even if the name is not in the array....please help
Code:
private static void searchAthleteName(athlete[]ath, int size)
{
String athSurname = null;
String athForename = null;
My.p("\n\t\t\tS E A R C H B Y N A M E ");
My.p("\n\n\tEnter Athlete Surname : "); athSurname = key.nextLine();
My.p("\n\tEnter Athlete Forename : "); athForename = key.nextLine();
My.p("\nAthlete No Surname Forename Date of Birth Best Time");
for(int x = 0; x < size; x++)
{
if (athSurname.equals(athSurname) && athForename.equals(athForename))
{
My.p(ath[x].toString());
}
else
{
My.p("\n\t\tNot a Valid Name ");
}
}
My.pressKey(2);
}