Java String Capitalize capitalise(String s)

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

Description

Converts a string to all lower case, and capitalises the first letter of the string

License

Open Source License

Parameter

Parameter Description
s unformated string.

Return

The formated string.

Declaration

public static String capitalise(String s) 

Method Source Code

//package com.java2s;
/*//from w w w.j  ava 2 s .  c o  m
 * Copyright (c) 2004-2012 The YAWL Foundation. All rights reserved.
 * The YAWL Foundation is a collaboration of individuals and
 * organisations who are committed to improving workflow technology.
 *
 * This file is part of YAWL. YAWL is free software: you can
 * redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation.
 *
 * YAWL is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
 * Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with YAWL. If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Converts a string to all lower case, and capitalises the first letter of the string
     *
     * @param s unformated string.
     * @return The formated string.
     */
    public static String capitalise(String s) {
        if ((s == null) || (s.length() == 0))
            return s;
        char[] chars = s.toLowerCase().toCharArray();
        chars[0] = Character.toUpperCase(chars[0]);
        return String.valueOf(chars);
    }
}

Related

  1. capitalise(final String name)
  2. capitalise(String line)
  3. capitalise(String name)
  4. capitalise(String s)
  5. capitalise(String s)
  6. capitalise(String s)
  7. capitalise(String str)