Here is a code fragment that deals with ending the method.
public boolean recognize(String str) { final int reject = 3; int state = 0; char current; int index = 0 while ( index < && state != ) { current = str.charAt( index++ ); . . . . . }
Mentally fill in the blanks (then click to see if you are right).