Java String Title Case titleCase(String name)

Here you can find the source of titleCase(String name)

Description

Return the string in Titlecase, i.e.

License

Open Source License

Parameter

Parameter Description
name a parameter

Return

titlecased string

Declaration

public static String titleCase(String name) 

Method Source Code

//package com.java2s;
/*/*from  ww w.j  a v  a  2s.  c o  m*/
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/

public class Main {
    /**
     * Return the string in Titlecase, i.e. the first character is capitalized.
     * If the first character is not a letter, there is no change.
     * @param name
     * @return titlecased string
     */
    public static String titleCase(String name) {
        if (name.length() == 0)
            return name;
        return Character.toUpperCase(name.charAt(0)) + name.substring(1);
    }
}

Related

  1. titleCase(final String input)
  2. titleCase(final String s)
  3. titleCase(final String text)
  4. titleCase(String in)
  5. titleCase(String input)
  6. titleCase(String raw)
  7. titleCase(String realName)
  8. titleCase(String s)
  9. titleCase(String str)