Java String Lower Case toLowerCase(String string)

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

Description

A locale independent version of toLowerCase.

License

Apache License

Parameter

Parameter Description
string input to be converted

Return

a US ASCII lowercase version

Declaration

public static String toLowerCase(String string) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/* ww  w  . j av a2 s.co  m*/
     * A locale independent version of toLowerCase.
     *
     * @param string input to be converted
     * @return a US ASCII lowercase version
     */
    public static String toLowerCase(String string) {
        boolean changed = false;
        char[] chars = string.toCharArray();

        for (int i = 0; i != chars.length; i++) {
            char ch = chars[i];
            if ('A' <= ch && 'Z' >= ch) {
                changed = true;
                chars[i] = (char) (ch - 'A' + 'a');
            }
        }

        if (changed) {
            return new String(chars);
        }

        return string;
    }
}

Related

  1. toLowerCase(String str)
  2. toLowerCase(String str)
  3. toLowerCase(String str)
  4. toLowerCase(String str)
  5. toLowerCase(String str)
  6. toLowerCase(String string)
  7. toLowerCase(String text)
  8. toLowerCase(String text)
  9. toLowerCase(String text)