Here you can find the source of capitalize(String s)
Parameter | Description |
---|---|
s | input string |
public static String capitalize(String s)
//package com.java2s; public class Main { /**//w w w . ja v a 2 s . c om * Capitalizes first character of the string * * @param s * input string * @return capitalized string */ public static String capitalize(String s) { if (s == null || s.length() == 0) { return ""; } char first = s.charAt(0); if (Character.isUpperCase(first)) { return s; } else { return Character.toUpperCase(first) + s.substring(1); } } }