Java String Capitalize capitalize(final String str)

Here you can find the source of capitalize(final String str)

Description

capitalize

License

Open Source License

Declaration

public static String capitalize(final String str) 

Method Source Code

//package com.java2s;
/*//w  ww.j  a v a 2 s . c o  m
 License:
    
 blueprint-sdk is licensed under the terms of Eclipse Public License(EPL) v1.0
 (http://www.eclipse.org/legal/epl-v10.html)
    
    
 Distribution:
    
 Repository - https://github.com/lempel/blueprint-sdk.git
 Blog - http://lempel.egloos.com
 */

public class Main {
    public static String capitalize(final String str) {
        String result = null;

        if (str != null) {
            if (str.length() >= 2) {
                result = str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase();
            } else {
                result = str.toUpperCase();
            }
        }

        return result;
    }
}

Related

  1. capitalize(final String s)
  2. capitalize(final String s)
  3. capitalize(final String s)
  4. capitalize(final String str)
  5. capitalize(final String str)
  6. capitalize(final String str)
  7. capitalize(final String str)
  8. capitalize(final String str)
  9. capitalize(final String str)