Here you can find the source of capitalize(String name)
public static String capitalize(String name)
//package com.java2s; public class Main { /**// w w w .j ava 2s . c o m * This method capitalizes the first character in the provided string. * @return resulted string */ public static String capitalize(String name) { int len = name.length(); StringBuffer sb = new StringBuffer(len); boolean setCap = true; for (int i = 0; i < len; i++) { char c = name.charAt(i); if (c == '-' || c == '_') { setCap = true; } else { if (setCap) { sb.append(Character.toUpperCase(c)); setCap = false; } else { sb.append(c); } } } return sb.toString(); } }