public static boolean isLegalIdentifier(String name){
  if (name.isEmpty()) {
    return false;
  }
  if (!Character.isJavaIdentifierStart(name.charAt(0))) {
    return false;
  }
  int i=1;
  while (i < name.length()) {
    if (!Character.isJavaIdentifierPart(name.charAt(i))) {
      return false;
    }
    i=i + 1;
  }
  return true;
}

public static boolean isLegalIdentifier ( String name ) { if ( name . isEmpty ( ) ) { return false ; } if ( ! Character . isJavaIdentifierStart ( name . charAt ( 0 ) ) ) { return false ; } int i = 1 ; while ( i < name . length ( ) ) { if ( ! Character . isJavaIdentifierPart ( name . charAt ( i ) ) ) { return false ; } i = i + 1 ; } return true ; }
a good - enough approximation : is the argument a legal identifier in java ?
