Here you can find the source of toJavaIdentifier(String name)
public static String toJavaIdentifier(String name)
//package com.java2s; //License from project: Apache License public class Main { public static String toJavaIdentifier(String name) { StringBuilder s = new StringBuilder(); boolean capitalize = false; for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if ((i != 0 && !Character.isJavaIdentifierStart(ch)) || !Character.isJavaIdentifierPart(ch)) { capitalize = true;// w w w.j a va 2 s. c om } else if (capitalize) { s.append(Character.toUpperCase(ch)); capitalize = false; } else s.append(ch); } return lowerFirst(s.toString()); } public static String lowerFirst(String s) { return s.substring(0, 1).toLowerCase() + s.substring(1); } }