Here you can find the source of capitalise(String str)
Parameter | Description |
---|---|
str | the String to capitalise |
public static String capitalise(String str)
//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()); } }