Java程序 检查输入的值是否是ASCII 7位控制字符
要检查输入的值是否是ASCII 7位控制字符,请检查字符的ASCII值在32和127之前。这些就是控制字符。
在这里,我们有一个字符。
char one = ' n ';
现在,我们用if-else检查一个条件,以检查字符是否小于32(ASCII)并等于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!");
}例子
public class Demo {
public static void main(String []args) {
char one = '
';
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!");
}
}
}输出
Given value is a control character!
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
安卓
Python
C编程
C++
C#
MongoDB
MySQL
Javascript
PHP