Java String Upper Case toUpperCaseFirstChar(String str)

Here you can find the source of toUpperCaseFirstChar(String str)

Description

set the first character into low case.

License

Open Source License

Parameter

Parameter Description
str a parameter

Return

str with the first char upper-cased

Declaration

public static String toUpperCaseFirstChar(String str) 

Method Source Code

//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;
    }
}

Related

  1. toUpperCaseFirst(String text)
  2. toUpperCaseFirst(String text)
  3. toUpperCaseFirstAll(String text)
  4. toUpperCaseFirstChar(final String str)
  5. toUpperCaseFirstChar(String s)
  6. toUpperCaseFirstChar(String str)
  7. toUpperCaseFirstChar(String string)
  8. toUpperCaseFirstChar(String string)
  9. toUpperCaseFirstChar(String text)