Java String Capitalize capitalise(String str)

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

Description

Returns a capitalised version of the given String

License

GNU General Public License

Parameter

Parameter Description
str the String to capitalise

Return

the capitalised version of str

Declaration

public static String capitalise(String str) 

Method Source Code

//package com.java2s;
/*//w  w w  . ja  v a2s. co m
 * Copyright (C) 2002-2017 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

public class Main {
    /**
     * Returns a capitalised version of the given String
     *
     * @param str the String to capitalise
     * @return the capitalised version of str
     */
    public static String capitalise(String str) {
        if (str == null) {
            return null;
        }
        if (str.length() <= 1) {
            return str.toUpperCase();
        }
        return str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
    }
}

Related

  1. capitalise(String name)
  2. capitalise(String s)
  3. capitalise(String s)
  4. capitalise(String s)
  5. capitalise(String s)
  6. capitalise(String str)
  7. capitalise(String str)
  8. capitalise(String string)
  9. capitalise(String string)