public static boolean isValid ( String name ) { char [ ] nameChars = name . toCharArray ( ) ; for ( int i = 0 ; i < nameChars . length ; i ++ ) { boolean valid = i == 0 ? Character . isJavaIdentifierStart ( nameChars [ i ] ) : Character . isJavaIdentifierPart ( nameChars [ i ] ) ; if ( ! valid ) { return valid ; } } return true ; }
Test if an identifier is valid .