Here you can find the source of capitalize(CharSequence s)
public static String capitalize(CharSequence s)
//package com.java2s; //License from project: Apache License public class Main { public static String capitalize(CharSequence s) { if (null == s) return null; int len = s.length(); if (len == 0) return ""; char char0 = s.charAt(0); if (Character.isUpperCase(char0)) return s.toString(); return new StringBuilder(len).append(Character.toUpperCase(char0)).append(s.subSequence(1, len)).toString(); }/* ww w . j a v a2s .c o m*/ }