Android String Capitalize decapitalize(String string)

Here you can find the source of decapitalize(String string)

Description

Decapitalize a String if it begins with a capital letter, e.g.: FooBar -> fooBar

License

Open Source License

Parameter

Parameter Description
string a String

Return

a decapitalized String

Declaration

public static String decapitalize(String string) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  ww  w  .  ja v  a  2  s . c  om*/
     * Decapitalize a String if it begins with a capital letter, e.g.:
     * FooBar -> fooBar
     *
     * @param string a String
     * @return a decapitalized String
     */
    public static String decapitalize(String string) {
        char c0 = string.charAt(0);
        if (!Character.isUpperCase(c0)) {
            return string;
        }
        if (string.length() > 1 && Character.isUpperCase(string.charAt(1))) {
            return string;
        }
        char[] chars = string.toCharArray();
        chars[0] = Character.toLowerCase(c0);
        return new String(chars);
    }
}

Related

  1. capitalize(String str)
  2. capitalize(String s)
  3. capitalize(final String name)
  4. decapitalize(final String name)
  5. capitalize(String string)
  6. capitalizeFirstLetter(String str)
  7. capitalize(String line)
  8. capitalize(String s)