Here you can find the source of capitalizeFirst(String string)
Parameter | Description |
---|---|
string | The string to have its first letter capitalized |
public static String capitalizeFirst(String string)
//package com.java2s; /*/*from w w w .ja v a 2 s. co m*/ * net/balusc/util/StringUtil.java * * Copyright (C) 2007 BalusC * * This program is free software: you can redistribute it and/or modify it under the terms of the * GNU Lesser General Public License as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * 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. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this library. * If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Capitalize the first letter of the given string * @param string The string to have its first letter capitalized * @return The string with its first letter capitalized or a blank string * if string was null. */ public static String capitalizeFirst(String string) { if (string != null) { return (string.substring(0, 1).toUpperCase() + string.substring(1, string.length())); } else { return ""; } } }