Java 程序检查字符是否为 7 位 ASCII 码
检查字符是否为 7 位 ASCII 码,检查给定值的 ASCII 值是否小于 128。
这里我们有一个字符。
char one = '-';
现在,我们借助 if-else 语句检查了 7 位 ASCII 码字符的条件。
if (c < 128) {
System.out.println("Given value is ASCII 7 bit!");
} else {
System.out.println("Given value is not an ASCII 7 bit!");
}以下是在其中检查字符的 7 位 ASCII 码的示例。
示例
public class Demo {
public static void main(String []args) {
char c = '-';
System.out.println("Given value = "+c);
if ( c < 128) {
System.out.println("Given value is ASCII 7 bit!");
} else {
System.out.println("Given value is not an ASCII 7 bit!");
}
}
}输出
Given value = * Given value is ASCII 7 bit!
我们来看看一个示例,其中我们有一个字符,并检查输入的值是否为 7 位 ASCII 码。
示例
public class Demo {
public static void main(String []args) {
char c = 'u';
System.out.println("Given value = "+c);
if ( c < 128) {
System.out.println("Given value is ASCII 7 bit!");
} else {
System.out.println("Given value is not an ASCII 7 bit!");
}
}
}输出
Given value = u Given value is ASCII 7 bit!
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP