Here you can find the source of capitalize(CharSequence s)
public static CharSequence capitalize(CharSequence s)
//package com.java2s; public class Main { public static CharSequence capitalize(CharSequence s) { if (isNotBlank(s) && !Character.isUpperCase(s.charAt(0))) { final StringBuilder sb = new StringBuilder(s); sb.setCharAt(0, Character.toUpperCase(s.charAt(0))); return sb.toString(); }/*from w w w .ja v a 2 s.com*/ return s; } public static boolean isNotBlank(final CharSequence s) { if (s != null) { int len = s.length(); for (int i = 0; i < len; i++) { if (!Character.isWhitespace(s.charAt(i))) { return true; } } } return false; } }