Here you can find the source of capitalize(final String text)
private static String capitalize(final String text)
//package com.java2s; /*//from w ww.j ava 2s. co m * Debrief - the Open Source Maritime Analysis Application * http://debrief.info * * (C) 2000-2014, PlanetMayo Ltd * * This library is free software; you can redistribute it and/or * modify it under the terms of the Eclipse Public License v1.0 * (http://www.eclipse.org/legal/epl-v10.html) * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ public class Main { private static String capitalize(final String text) { if (text == null) { throw new NullPointerException(); } if (text.length() == 0) { return text; } final char firstChar = text.charAt(0); return Character.isUpperCase(firstChar) ? text : Character.toUpperCase(firstChar) + text.substring(1); } }