

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Java Program to check whether the character is ASCII 7 bit numeric
To check whether the entered value is ASCII 7-bit numeric, check the character from ‘0’ to ‘9’.
Here, we have a numeric character.
char one = '9';
Now, we have checked a condition with if-else for numeric character from ‘0’ to ‘9’
if (c >= '0' && c <= '9') { System.out.println("Given value is numeric!"); } else { System.out.println("Given value is not numeric!"); }
Example
public class Demo { public static void main(String []args) { char c = '9'; System.out.println("Given value = "+c); if (c >= '0' && c <= '9') { System.out.println("Given value is numeric!"); } else { System.out.println("Given value is not numeric!"); } } }
Output
Given value = 9 Given value is numeric!
Let us see another example wherein we check for numeric character. But, here the given value to be checked is not numeric.
Example
Public class Demo { public static void main(String []args) { char c = 's'; System.out.println("Given value = "+c); if (c >= '0' && c <= '9') { System.out.println("Given value is numeric!"); } else { System.out.println("Given value is not numeric!"); } } }
Output
Given value = s Given value is not numeric!
Let us see one more example now wherein we check for numeric character. But, here the given value to be checked is not numeric.
Example
public class Demo { public static void main(String []args) { char c = '-'; System.out.println("Given value = "+c); if (c >= '0' && c <= '9') { System.out.println("Given value is numeric!"); } else { System.out.println("Given value is not numeric!"); } } }
Output
Given value = - Given value is not numeric!
- Related Questions & Answers
- Java Program to check whether the entered character is ASCII 7 bit numeric and 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 control character
- 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 a Character is Alphabet or Not
- 8085 program to add even parity to a string of 7 bit ASCII characters.
- Java Program to Check if a String is Numeric
- C++ Program to Check Whether a character is Vowel or Consonant
- 8085 program to check whether the given 16 bit number is palindrome or not
- Check whether the Unicode character is a separator character in C#
- Java Program to Check Whether the Given String is Pangram
- Check whether a character is Lowercase or not in Java
Advertisements