Here you can find the source of titleCase(String name)
Parameter | Description |
---|---|
name | a parameter |
public static String titleCase(String name)
//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); } }