Here you can find the source of capitalize(String s)
Parameter | Description |
---|---|
s | String |
public static String capitalize(String s)
//package com.java2s; public class Main { /**/* w w w. ja va 2s . c om*/ * capitalize. * @param s String * @return String */ public static String capitalize(String s) { if (isEmpty(s)) { return s; } return Character.toTitleCase(s.charAt(0)) + s.substring(1); } /** * whether or not the string is null or consists only of whitespace. * @param s * @return boolean * */ public static boolean isEmpty(String s) { return s == null || s.trim().length() == 0; } }