Java String Upper Case toUpperCaseFirstChar(final String str)

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

Description

Method used to change to upper case the first character of a given string.

License

Open Source License

Parameter

Parameter Description
str the string

Return

str with the first character of the string in upper case.

Declaration

public static String toUpperCaseFirstChar(final String str) 

Method Source Code

//package com.java2s;
/* ******************************************************************************
 * Copyright (c) 2011 SouthEdge Software and Consultancy.  
 * 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:/* w  w  w . ja  v  a 2s. co m*/
 *     Carl Frendo - initial design and implementation
 * ******************************************************************************/

public class Main {
    /**
     * Method used to change to upper case the first character of a given string.
     * 
     * @param str the string
     * @return str with the first character of the string in upper case.
     */
    public static String toUpperCaseFirstChar(final String str) {
        String firstChar = str.substring(0, 1);
        firstChar = firstChar.toUpperCase();
        String lastChars = str.substring(1, str.length());
        return firstChar + lastChars;
    }
}

Related

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