Here you can find the source of toUpperCaseFirstChar(String str)
Parameter | Description |
---|---|
str | a parameter |
public static String toUpperCaseFirstChar(String str)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2005 Sybase, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from ww w .j a v a 2s . c om*/ * Sybase, Inc. - initial API and implementation *******************************************************************************/ public class Main { /** * set the first character into low case. * * @param str * @return str with the first char upper-cased */ public static String toUpperCaseFirstChar(String str) { // change the first alphabet to lowcase. if (str != null && str.length() > 0) { if (str.length() == 1) { str = str.toUpperCase(); } else { str = str.substring(0, 1).toUpperCase() + str.substring(1); } } return str; } }