private static String correctReservedWord(String str){
  char first=str.charAt(0);
switch (first) {
case 'a':
    if (str.equals("abstract"))     return "_" + str;
  break;
case 'b':
if (str.equals("boolean")) return "_" + str;
 else if (str.equals("break")) return "_" + str;
 else if (str.equals("byte")) return "_" + str;
break;
case 'c':
if (str.equals("case")) return "_" + str;
 else if (str.equals("catch")) return "_" + str;
 else if (str.equals("char")) return "_" + str;
 else if (str.equals("const")) return "_" + str;
 else if (str.equals("class")) return "_" + str;
 else if (str.equals("continue")) return "_" + str;
break;
case 'd':
if (str.equals("default")) return "_" + str;
 else if (str.equals("do")) return "_" + str;
 else if (str.equals("double")) return "_" + str;
break;
case 'e':
if (str.equals("else")) return "_" + str;
 else if (str.equals("extends")) return "_" + str;
 else if (str.equals("enum")) return "_" + str;
break;
case 'f':
if (str.equals("false")) return "_" + str;
 else if (str.equals("final")) return "_" + str;
 else if (str.equals("finally")) return "_" + str;
 else if (str.equals("float")) return "_" + str;
 else if (str.equals("for")) return "_" + str;
break;
case 'g':
if (str.equals("goto")) return "_" + str;
break;
case 'i':
if (str.equals("if")) return "_" + str;
 else if (str.equals("implements")) return "_" + str;
 else if (str.equals("import")) return "_" + str;
 else if (str.equals("instanceof")) return "_" + str;
 else if (str.equals("int")) return "_" + str;
 else if (str.equals("interface")) return "_" + str;
break;
case 'n':
if (str.equals("native")) return "_" + str;
 else if (str.equals("new")) return "_" + str;
 else if (str.equals("null")) return "_" + str;
break;
case 'p':
if (str.equals("package")) return "_" + str;
 else if (str.equals("private")) return "_" + str;
 else if (str.equals("protected")) return "_" + str;
 else if (str.equals("public")) return "_" + str;
break;
case 'r':
if (str.equals("return")) return "_" + str;
break;
case 's':
if (str.equals("short")) return "_" + str;
 else if (str.equals("static")) return "_" + str;
 else if (str.equals("strictfp")) return "_" + str;
 else if (str.equals("super")) return "_" + str;
 else if (str.equals("switch")) return "_" + str;
 else if (str.equals("synchronized")) return "_" + str;
break;
case 't':
if (str.equals("this")) return "_" + str;
 else if (str.equals("throw")) return "_" + str;
 else if (str.equals("throws")) return "_" + str;
 else if (str.equals("transient")) return "_" + str;
 else if (str.equals("true")) return "_" + str;
 else if (str.equals("try")) return "_" + str;
break;
case 'v':
if (str.equals("void")) return "_" + str;
 else if (str.equals("volatile")) return "_" + str;
break;
case 'w':
if (str.equals("while")) return "_" + str;
break;
}
return str;
}

private static String correctReservedWord ( String str ) { char first = str . charAt ( 0 ) ; switch ( first ) { case 'a' : if ( str . equals ( "abstract" ) ) return "_" + str ; break ; case 'b' : if ( str . equals ( "boolean" ) ) return "_" + str ; else if ( str . equals ( "break" ) ) return "_" + str ; else if ( str . equals ( "byte" ) ) return "_" + str ; break ; case 'c' : if ( str . equals ( "case" ) ) return "_" + str ; else if ( str . equals ( "catch" ) ) return "_" + str ; else if ( str . equals ( "char" ) ) return "_" + str ; else if ( str . equals ( "const" ) ) return "_" + str ; else if ( str . equals ( "class" ) ) return "_" + str ; else if ( str . equals ( "continue" ) ) return "_" + str ; break ; case 'd' : if ( str . equals ( "default" ) ) return "_" + str ; else if ( str . equals ( "do" ) ) return "_" + str ; else if ( str . equals ( "double" ) ) return "_" + str ; break ; case 'e' : if ( str . equals ( "else" ) ) return "_" + str ; else if ( str . equals ( "extends" ) ) return "_" + str ; else if ( str . equals ( "enum" ) ) return "_" + str ; break ; case 'f' : if ( str . equals ( "false" ) ) return "_" + str ; else if ( str . equals ( "final" ) ) return "_" + str ; else if ( str . equals ( "finally" ) ) return "_" + str ; else if ( str . equals ( "float" ) ) return "_" + str ; else if ( str . equals ( "for" ) ) return "_" + str ; break ; case 'g' : if ( str . equals ( "goto" ) ) return "_" + str ; break ; case 'i' : if ( str . equals ( "if" ) ) return "_" + str ; else if ( str . equals ( "implements" ) ) return "_" + str ; else if ( str . equals ( "import" ) ) return "_" + str ; else if ( str . equals ( "instanceof" ) ) return "_" + str ; else if ( str . equals ( "int" ) ) return "_" + str ; else if ( str . equals ( "interface" ) ) return "_" + str ; break ; case 'n' : if ( str . equals ( "native" ) ) return "_" + str ; else if ( str . equals ( "new" ) ) return "_" + str ; else if ( str . equals ( "null" ) ) return "_" + str ; break ; case 'p' : if ( str . equals ( "package" ) ) return "_" + str ; else if ( str . equals ( "private" ) ) return "_" + str ; else if ( str . equals ( "protected" ) ) return "_" + str ; else if ( str . equals ( "public" ) ) return "_" + str ; break ; case 'r' : if ( str . equals ( "return" ) ) return "_" + str ; break ; case 's' : if ( str . equals ( "short" ) ) return "_" + str ; else if ( str . equals ( "static" ) ) return "_" + str ; else if ( str . equals ( "strictfp" ) ) return "_" + str ; else if ( str . equals ( "super" ) ) return "_" + str ; else if ( str . equals ( "switch" ) ) return "_" + str ; else if ( str . equals ( "synchronized" ) ) return "_" + str ; break ; case 't' : if ( str . equals ( "this" ) ) return "_" + str ; else if ( str . equals ( "throw" ) ) return "_" + str ; else if ( str . equals ( "throws" ) ) return "_" + str ; else if ( str . equals ( "transient" ) ) return "_" + str ; else if ( str . equals ( "true" ) ) return "_" + str ; else if ( str . equals ( "try" ) ) return "_" + str ; break ; case 'v' : if ( str . equals ( "void" ) ) return "_" + str ; else if ( str . equals ( "volatile" ) ) return "_" + str ; break ; case 'w' : if ( str . equals ( "while" ) ) return "_" + str ; break ; } return str ; }
if given string is a keyword it will be replaced with none keyword
