
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check ASCII 7-Bit Alphabetic Lowercase in Java
In this article, we'll learn how to check whether the entered value is ASCII 7-bit alphabetic lowercase in Java. In ASCII, the lowercase alphabets begin with the character ?a' and end with ?z'. We will write a program checking whether a character is a lowercase alphabetic character using a simple if-else statement.
Problem Statement
We are given a character, and we need to create a Java program that checks whether the character is a lowercase letter in the ASCII 7-bit range, meaning it falls between 'a' and 'z'. We will also check if the character is uppercase, meaning it falls between 'A' and 'Z'. It will print whether the character is a lowercase letter, an uppercase letter, or neither.
Input 1
char one = 'm';Output 1
Character: m
Given character is in lowercase!
Input 2
char one = 'N';Output 2
Character: N
Given character is not in lowercase!
Different approaches
Checking a lowercase ASCII letter
The following are the steps to check if a character is a lowercase ASCII letter ?
- Define the character variable and assign the value 'm'.
- Use an if-else statement to check if the character is between 'a' and 'z'.
- If true, print that the character is in lowercase.
Example
Below is a Java program to check if a character is a lowercase ASCII letter ?
public class Demo { public static void main(String []args) { char one = 'm'; System.out.println("Character: "+one); if (one >= 'a' && one <= 'z') { System.out.println("Given character is in lowercase!"); } else { System.out.println("Given character is not in lowercase!"); } } }
Output
Character: m Given character is in lowercase!
Checking an Uppercase ASCII Letter
The following are the steps to check if a character is an uppercase ASCII letter ?
- Define the character variable and assign the value 'N'.
- Use an if-else statement to check if the character is between 'a' and 'z'.
- If false, print that the character is not in lowercase.
Example
Below is a Java program to check if a character is an uppercase ASCII letter ?
public class Demo { public static void main(String []args) { char one = 'N'; System.out.println("Character: "+one); if (one >= 'a' && one <= 'z') { System.out.println("Given character is in lowercase!"); } else { System.out.println("Given character is not in lowercase!"); } } }
Output
Character: N Given character is not in lowercase!