Java Check ASCII Character is UPPERCASE using Google Guava
Tags: Google Guava Ascii char
In this Java tutorial we learn how to use the com.google.common.base.Ascii class of Google Guava library to indicate whether an ASCII character is an uppercase character.
How to add Google Guava library to the Java project
To use the Google Guava library in the Gradle build project, add the following dependency into the build.gradle file.
implementation group: 'com.google.guava', name: 'guava', version: '30.1.1-jre'
To use the Google Guava library in the Maven build project, add the following dependency into the pom.xml file.
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
</dependency>
To have more information about the Google Guava library you can visit the project home page at guava.dev
How to check a char value is uppercase in Java
To check whether a char value is uppercase or not in Java we can use the Ascii.isUpperCase() method of Google Guava library. We show you how to use the Ascii.isUpperCase() method in the following Java example program.
AsciiIsUpperCaseExample.java
import com.google.common.base.Ascii;
public class AsciiIsUpperCaseExample {
public static void main(String... args) {
boolean result1 = Ascii.isUpperCase('a');
boolean result2 = Ascii.isUpperCase('A');
boolean result3 = Ascii.isUpperCase('1');
boolean result4 = Ascii.isUpperCase('@');
System.out.println("'a' is uppercase: " + result1);
System.out.println("'A' is uppercase: " + result2);
System.out.println("'1' is uppercase: " + result3);
System.out.println("'@' is uppercase: " + result4);
}
}
'a' is uppercase: false
'A' is uppercase: true
'1' is uppercase: false
'@' is uppercase: false
Happy Coding 😊