This is one of my method in my program. When I tried to search for the course code from one of the selection of characters: j, g, or t; it only prints the first line it finds and never searches for the next course code.
NKDSG Foo 12.1 5 T
YDSSE Kim 12.1 5 J
ESATF Lar 23.5 10 J
private Dogs searchForDogsByCourse(String dogsCode)
{
System.out.printf("%27s%27s%27s%27s%n","ID","Name","Running Time","Penalty");
int i = 0;
for(Dogs dogs : dogsList)
{
i++;
if(dogs.getCourseCode().equalsIgnoreCase(dogsCode))
{
System.out.printf("%27s%27s%27.2f%27d",dogs.getDogId(),
dogs.getName(), dogs.getDogRuntime(), dogs.getPenalty());
}
}
return null;
}
When I searched for J, it only prints first one it matches and ends the loop.
ID Name Running Time Penalty
YDSSE Kim 12.1 5