string - how to convert "user_id" to "userId" in Java? -


convert string camelcase

eg: "user_id" "userid" "user_name" "username" "country_province_city" "countryprovincecity"

how in easy way?

ps:"country_province_city" should "countryprovincecity" not "countryprovincecity"

i use loop , stringbuilder. like

string[] arr = { "user_id", "user_name", "country_province_city" }; (string str : arr) {     stringbuilder sb = new stringbuilder(str);     int pos;     while ((pos = sb.indexof("_")) > -1) {         string ch = sb.substring(pos + 1, pos + 2);         sb.replace(pos, pos + 2, ch.touppercase());     }     system.out.printf("%s = %s%n", str, sb); } 

and (requested)

user_id = userid user_name = username country_province_city = countryprovincecity 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -