
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 If Value Is ASCII 7-Bit Control Character in Java
To check whether the entered value is ASCII 7-bit control character, check the characters ASCII value before 32 and 127. These are the control characters.
Here, we have a character.
char one = ' n ';
Now, we have checked a condition with if-else to check for character less than 32 (ASCII) and equal to 127.
if (one < 32 || one == 127) { System.out.println("Given value is a control character!"); } else { System.out.println("Given value is not a control character!"); }
Example
public class Demo { public static void main(String []args) { char one = '\n'; if (one < 32 || one == 127) { System.out.println("Given value is a control character!"); } else { System.out.println("Given value is not a control character!"); } } }
Output
Given value is a control character!
Advertisements