Java Check Character is ASCII Alphabetic Lower Case using Apache Commons Lang

Tags: Apache Commons Apache Commons Lang CharUtils char Character ASCII

In this Java tutorial we learn how to check whether a character is an ASCII alphabet lower case or not using the CharUtils class of Apache Commons Lang library.

How to add Apache Commons Lang 3 library to your Java project

To use the Apache Commons Lang 3 library in the Gradle build project, add the following dependency into the build.gradle file.

implementation 'org.apache.commons:commons-lang3:3.12.0'

To use the Apache Commons Lang 3 library in the Maven build project, add the following dependency into the pom.xml file.

<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
  <version>3.12.0</version>
</dependency>

To have more information about the Apache Commons Lang 3 library you can visit the library home page at commons.apache.org/proper/commons-lang/

How to check a character is alphabetic lower case in Java

The Apache Commons Lang library provides the method CharUtils.isAsciiAlphaLower() to check whether a given character is an ASCII alphabet lower case character or not. You can learn how to use the CharUtils.isAsciiAlphaLower() method in the following example code.

CheckIsAsciiAlphaLowerChar.java

import org.apache.commons.lang3.CharUtils;

public class CheckIsAsciiAlphaLowerChar {
    public static void main(String... args) {
        boolean result1 = CharUtils.isAsciiAlphaLower('a');
        boolean result2 = CharUtils.isAsciiAlphaLower('A');
        boolean result3 = CharUtils.isAsciiAlphaLower('7');
        boolean result4 = CharUtils.isAsciiAlphaLower('-');
        boolean result5 = CharUtils.isAsciiAlphaLower('\n');

        System.out.println("Character 'a' is ASCII alphabetic lower case result: " + result1);
        System.out.println("Character 'A' is ASCII alphabetic lower case result: " + result2);
        System.out.println("Character '7' is ASCII alphabetic lower case result: " + result3);
        System.out.println("Character '-' is ASCII alphabetic lower case result: " + result4);
        System.out.println("Character '\\n' is ASCII alphabetic lower case result: " + result5);
    }
}
The output is:
Character 'a' is ASCII alphabetic lower case result: true
Character 'A' is ASCII alphabetic lower case result: false
Character '7' is ASCII alphabetic lower case result: false
Character '-' is ASCII alphabetic lower case result: false
Character '\n' is ASCII alphabetic lower case result: false

Happy Coding 😊