You can do this in one of two ways in Java. There are break statements and using boolean statements you can take advantage of.
Break statements will break out of a loop right when it gets to the statement. So if we were to do
int i = 0;
while(true)
{
if(i > 3)
break;
i++
}
This loop would break when I becomes greater then three.
That is one way. The other way to separate execution would be to use a boolean variable to keep track of what is going on when. For example
boolean found = false;
for(int i = 0; i < somelist.length() && !found; i++)
{
if(something.equals(somethingelse))
found = true;
}
if(!found)
System.out.println("Not Found");
else
System.out.println("Found");
Greetings.