Here you can find the source of decapitalize(String string)
Parameter | Description |
---|---|
string | a String |
public static String decapitalize(String string)
//package com.java2s; public class Main { /**/*from w w w. j a va2 s. co m*/ * 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); } }