Implementation off the $1 Recognizer algorithm in Java