Here you can find the source of capitalize(String s)
public static String capitalize(String s)
//package com.java2s; // under the terms of the GNU Lesser General Public License as published public class Main { /**//w w w . j ava 2 s . com * Returns a version of the supplied string with the first letter capitalized. */ public static String capitalize(String s) { if (isBlank(s)) { return s; } char c = s.charAt(0); if (Character.isUpperCase(c)) { return s; } else { return String.valueOf(Character.toUpperCase(c)) + s.substring(1); } } /** * Returns true if the supplied string is null, zero length, or contains only whitespace. */ public static boolean isBlank(String text) { return (text == null) || (text.trim().length() == 0); } }