Here you can find the source of toCamelCase(String name)
Parameter | Description |
---|---|
name | the name |
private static String toCamelCase(String name)
//package com.java2s; //License from project: Apache License public class Main { /**//from w ww. j ava 2s. c o m * Method to convert case of string into camel case. * * @param name * the name * @return the string */ private static String toCamelCase(String name) { name = name.toLowerCase(); String[] parts = name.split(" "); String camelCaseString = parts[0].substring(0, 1).toLowerCase() + parts[0].substring(1); for (int i = 1; i < parts.length; i++) { camelCaseString = camelCaseString + toProperCase(parts[i]); } return camelCaseString; } /** * To proper case. * @param s * the s * @return the string */ private static String toProperCase(String s) { return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); } }