The entire automaton will be a Java class. To run the automaton, an automaton object will be constructed. Here is a skeleton of the class:
class FSAaz { public boolean recognize(String str) { . . . return true; . . . return false; } }
A conceptual finite state automaton (such as in the previous chapter) stops processing when there is no transition out of the current state for the current character. We don't want our Java method to halt. If the input string is rejected, the method should return false to its caller.
Add some state transitions to the automaton so that, for every state, any character other than the acceptable ones leads to a new "reject" state.