Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

charutils
java
communitycreator

What is CharUtils.isAsciiAlphaUpper in Java?

abhilash

Overview

The isAsciiAlphaUpper is a static method of CharUtils class that checks whether the input character is an uppercase letter. The method returns true if the ASCII value of the character is in the range of 97 to 122.

How to import CharUtils

CharUtils is defined in the Apache Commons Lang package. Apache Commons Lang can be added to the Maven project by adding the following dependency to the pom.xml file:

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

For other versions of the commons-lang package, refer to the Maven Repository.

We can import the CharUtils class as follows:

import org.apache.commons.lang3.CharUtils;

Syntax


public static boolean isAsciiAlphaUpper(final char ch)

Parameters

  • final char ch: Character to check

Return value

The function returns true if the character is an uppercase letter. Otherwise, it returns false.

Code

import org.apache.commons.lang3.CharUtils;

public class Main {

    public static void main(String[] args) {
        char c1 = 't';
        System.out.printf("The output of CharUtils.isAsciiAlphaUpper() for the character '%s' is %s", c1, CharUtils.isAsciiAlphaUpper(c1));
        System.out.println();

        c1 = 'È';
        System.out.printf("The output of CharUtils.isAsciiAlphaUpper() for the character '%s' is %s", c1, CharUtils.isAsciiAlphaUpper(c1));
        System.out.println();

        c1 = '9';
        System.out.printf("The output of CharUtils.isAsciiAlphaUpper() for the character '%s' is %s", c1, CharUtils.isAsciiAlphaUpper(c1));
        System.out.println();

        c1 = 'F';
        System.out.printf("The output of CharUtils.isAsciiAlphaUpper() for the character '%s' is %s", c1, CharUtils.isAsciiAlphaUpper(c1));
        System.out.println();
    }
}

Explanation

  • Character: ‘t’

    The method returns false because the character is a lowercase alphabet.

  • Character: ‘È’

    The method returns false because the character is not an uppercase alphabet.

  • Character: ‘9’

    The method returns false because the character is not an uppercase alphabet.

  • Character: ‘F’

    The method returns true because the character is an uppercase alphabet.

Expected output


The output of CharUtils.isAsciiAlphaUpper() for the character 't' is false
The output of CharUtils.isAsciiAlphaUpper() for the character 'È' is false
The output of CharUtils.isAsciiAlphaUpper() for the character '9' is false
The output of CharUtils.isAsciiAlphaUpper() for the character 'F' is true

RELATED TAGS

charutils
java
communitycreator
RELATED COURSES

View all Courses

Keep Exploring