Java String Uncapitalize uncapitalize(String source)

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

Description

Ensure that the first character of the provided string lower case.

License

Apache License

Parameter

Parameter Description
source The <code>String</code> to uncapitalize.

Return

The uncapitalized String.

Declaration

public static String uncapitalize(String source) 

Method Source Code

//package com.java2s;
/*/*from w  ww. j  ava  2  s  . c  om*/
 * Copyright 2001-2013 Geert Bevin (gbevin[remove] at uwyn dot com)
 * Licensed under the Apache License, Version 2.0 (the "License")
 */

public class Main {
    /**
     * Ensure that the first character of the provided string lower case.
     *
     * @param source The <code>String</code> to uncapitalize.
     * @return The uncapitalized <code>String</code>.
     * @since 1.5
     */
    public static String uncapitalize(String source) {
        if (source == null || source.length() == 0) {
            return source;
        }

        if (source.length() > 1 && Character.isLowerCase(source.charAt(0))) {
            return source;
        }

        char chars[] = source.toCharArray();
        chars[0] = Character.toLowerCase(chars[0]);
        return new String(chars);
    }
}

Related

  1. uncapitalize(String name)
  2. uncapitalize(String s)
  3. uncapitalize(String s)
  4. uncapitalize(String s)
  5. unCapitalize(String s)
  6. uncapitalize(String str)
  7. uncapitalize(String str)
  8. uncapitalize(String str)
  9. uncapitalize(String str)