Here you can find the source of uncapitalize(String str)
String
, changing the first letter to lower case as per Character#toLowerCase(char) .
Parameter | Description |
---|---|
str | the String to uncapitalize, may be <code>null</code> |
null
if null
public static String uncapitalize(String str)
//package com.java2s; public class Main { /**//from w w w . jav a 2 s . c om * Uncapitalize a <code>String</code>, changing the first letter to * lower case as per {@link Character#toLowerCase(char)}. * No other letters are changed. * @param str the String to uncapitalize, may be <code>null</code> * @return the uncapitalized String, <code>null</code> if null */ public static String uncapitalize(String str) { return changeFirstCharacterCase(str, false); } private static String changeFirstCharacterCase(String str, boolean capitalize) { if (str == null || str.length() == 0) { return str; } StringBuilder sb = new StringBuilder(str.length()); if (capitalize) { sb.append(Character.toUpperCase(str.charAt(0))); } else { sb.append(Character.toLowerCase(str.charAt(0))); } sb.append(str.substring(1)); return sb.toString(); } }