Java examples for java.lang:String Camel Case
Receives a word construct split in underscores and converts it to camelCase.
//package com.java2s; public class Main { /**/*from w w w.j a v a 2 s .c om*/ * Receives a word construct split in underscores and converts it to camelCase. * Example: virtual_machine --> virtualMachine * * @param wordConstruct the word construct to change its split. * @return the camelCased word construct */ public static String underscoreToCamelCase(String wordConstruct) { String[] words = wordConstruct.split("_"); String camelCaseWordConstruct = ""; for (String word : words) { if (!camelCaseWordConstruct.equals("")) { if (!word.equals("")) camelCaseWordConstruct += word.substring(0, 1) .toUpperCase() + word.substring(1); } else camelCaseWordConstruct += word; } return camelCaseWordConstruct; } }