- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to check whether the entered character is ASCII 7 bit numeric and character
To check whether the entered value is ASCII 7-bit numeric and character (alphanumeric), check the characters ASCII value for −
A to Z Or a to z Or 0 to 9
Here, we have the following value −
char one = '5';
Now, we have checked some conditions with if-else for ASCII 7-bit numeric and character.
if ((one >= 'A' && one <= 'Z') || (one >= 'a' && one <= 'z') || (one >= '0' && one <= '9')) { System.out.println("Given value is numeric and character (alphanumeric)!"); } else { System.out.println("Given value is not numeric and character!"); }
Example
public class Demo { public static void main(String []args) { char one = '5'; if ((one >= 'A' && one <= 'Z') || (one >= 'a' && one <= 'z') || (one >= '0' && one <= '9')) { System.out.println("Given value is numeric and character (alphanumeric)!"); } else { System.out.println("Given value is not numeric and character!"); } } }
Output
Given value is numeric and character (alphanumeric)!
Let us see another example −
Example
public class Demo { public static void main(String []args) { char one = 'V'; if ((one >= 'A' && one <= 'Z') || (one >= 'a' && one <= 'z') || (one >= '0' && one <= '9')) { System.out.println("Given value is numeric and character (alphanumeric)!"); } else { System.out.println("Given value is not numeric and character!"); } } }
Output
Given value is numeric and character (alphanumeric)!
- Related Articles
- Java Program to check whether the character is ASCII 7 bit numeric
- Java Program to check whether the entered value is ASCII 7-bit control character
- Java Program to check whether the character is ASCII 7 bit
- Java Program to check whether the character is ASCII 7 bit printable
- Java Program to check whether the entered value is ASCII 7 bit alphabetic
- Java Program to check whether the entered value is ASCII 7-bit alphabetic lowercase
- Java Program to check whether the entered value is ASCII 7 bit alphabetic uppercase
- Java Program to check whether the entered character a digit, white space, lower case or upper case character
- C Program to check the type of character entered
- Java Program to Check Whether a Character is Alphabet or Not
- Check whether the Unicode character is a separator character in C#
- Java program to print ASCII value of a particular character
- JAVA Menu Driven Program to Check Character is String, Number or Special Character
- C++ Program to Check Whether a character is Vowel or Consonant
- Haskell Program to Check Whether a Character is Alphabet or Not

Advertisements