Java String Title Case toTitleCase(String str)

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

Description

Converts the specified string to title case, by capitalizing the first letter.

License

Open Source License

Parameter

Parameter Description
str The string

Declaration

public static String toTitleCase(String str) 

Method Source Code

//package com.java2s;
/*/*from   ww w .j a v a2s . com*/
Copyright 2007-2009 QSpin - www.qspin.be
    
This file is part of QTaste framework.
    
QTaste 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, either version 3 of the License, or
(at your option) any later version.
    
QTaste 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 QTaste. If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    /**
     * Converts the specified string to title case, by capitalizing the
     * first letter.
     * @param str The string
     * @since jEdit 4.0pre1
     */
    public static String toTitleCase(String str) {
        if (str.length() == 0)
            return str;
        else {
            return Character.toUpperCase(str.charAt(0)) + str.substring(1).toLowerCase();
        }
    }
}

Related

  1. toTitleCase(String original)
  2. toTitleCase(String s)
  3. toTitleCase(String s)
  4. toTitleCase(String sIn)
  5. toTitleCase(String str)
  6. toTitleCase(String string)
  7. toTitleCase(String string)
  8. toTitleCase(String text)
  9. toTitleCase(String title)