Java String Uncapitalize uncapitalize(final String str)

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

Description

Put first letter into lowercase

License

Open Source License

Parameter

Parameter Description
str a parameter

Return

transformed string

Declaration

public static String uncapitalize(final String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w w w .  j ava  2  s . c o m
     * Put first letter into lowercase
     *
     * @param str
     * @return transformed string
     */
    public static String uncapitalize(final String str) {
        if (str.length() > 1) {
            return str.substring(0, 1).toLowerCase() + str.substring(1);
        } else {
            return str.toUpperCase();
        }
    }

    /**
     * a 'safe' @link {@link String#substring(int, int)} that does not throw exceptions when indexes are false.
     *
     * @param s
     *            any string
     * @param startIndex
     *            start index (maybe greater that endIndex)
     * @param endIndex
     *            required end index (may greater that the string itself)
     * @return substring
     */
    public static String substring(final String s, int startIndex, int endIndex) {
        startIndex = Math.min(s.length(), Math.max(0, startIndex));
        endIndex = Math.min(s.length(), Math.max(0, endIndex));
        return s.substring(Math.min(startIndex, endIndex), Math.max(startIndex, endIndex));
    }
}

Related

  1. uncapitalize(final CharSequence s)
  2. uncapitalize(final CharSequence sequence)
  3. uncapitalize(final String s)
  4. uncapitalize(final String str)
  5. uncapitalize(final String str)
  6. unCapitalize(String data, int pos)
  7. uncapitalize(String input)
  8. uncapitalize(String name)
  9. uncapitalize(String name)