Here you can find the source of capitalize(String s)
public static String capitalize(String s)
//package com.java2s; /*/*from w ww . jav a2 s.co m*/ * Copyright (c) 2014 Denis Solonenko. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v2.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ public class Main { public static String capitalize(String s) { if (s == null || s.length() == 0) return s; char[] stringArray = s.toCharArray(); stringArray[0] = Character.toUpperCase(stringArray[0]); return new String(stringArray); } }