public static boolean isNonterminal(String token){
  return (token.length() >= 3 && token.charAt(0) == '[') && (token.charAt(token.length() - 1) == ']');
}

public static boolean isNonterminal ( String token ) { return ( token . length ( ) >= 3 && token . charAt ( 0 ) == '[' ) && ( token . charAt ( token . length ( ) - 1 ) == ']' ) ; }
determines whether the string is a nonterminal by checking that the first character is [ and the last character is ] .
