Java Char Lower Case toLowerCase(char ch)

Here you can find the source of toLowerCase(char ch)

Description

If the character is an upper-case US-ASCII letter, it returns the lower-case version of that letter; otherwise, it just returns the character.

License

BSD License

Parameter

Parameter Description
ch The character to lower-case (if it is a US-ASCII upper-case character).

Return

The lower-case version of the character.

Declaration

public static final char toLowerCase(char ch) 

Method Source Code

//package com.java2s;
/*//from w w  w . j  a  v a2  s . c o  m
 * 08/06/2004
 *
 * RSyntaxUtilities.java - Utility methods used by RSyntaxTextArea and its
 * views.
 * 
 * This library is distributed under a modified BSD license.  See the included
 * RSyntaxTextArea.License.txt file for details.
 */

public class Main {
    /**
     * If the character is an upper-case US-ASCII letter, it returns the
     * lower-case version of that letter; otherwise, it just returns the
     * character.
     *
     * @param ch The character to lower-case (if it is a US-ASCII upper-case
     *        character).
     * @return The lower-case version of the character.
     */
    public static final char toLowerCase(char ch) {
        // We can logical OR with 32 because A-Z are 65-90 in the ASCII table
        // and none of them have the 6th bit (32) set, and a-z are 97-122 in
        // the ASCII table, which is 32 over from A-Z.
        // We do it this way as we'd need to do two conditions anyway (first
        // to check that ch<255 so it can index into our table, then whether
        // that table position has the upper-case mask).
        if (ch >= 'A' && ch <= 'Z')
            return (char) (ch | 0x20);
        return ch;
    }
}

Related

  1. toLowerCase(char b)
  2. toLowerCase(char c)
  3. toLowerCase(char c)
  4. toLowerCase(char c)
  5. toLowerCase(char ch)
  6. toLowerCase(char[] chars)
  7. toLowerCase(char[] cs)
  8. toLowerCase(char[] input)