Here you can find the source of toCamelCase(String str)
Parameter | Description |
---|---|
str | a parameter |
public static String toCamelCase(String str)
//package com.java2s; //License from project: Open Source License public class Main { /**//ww w. ja va 2 s .com * Convert a string to CamelCase * @param str * @return */ public static String toCamelCase(String str) { String[] wordList = str.toLowerCase().split("_"); String finalStr = ""; for (String word : wordList) { finalStr += capitalize(word); } return finalStr; } public static String capitalize(String line) { return Character.toUpperCase(line.charAt(0)) + line.substring(1); } }