Java 程序打印特定字符的 ASCII 值
java 8object oriented programmingprogramming更新于 2025/9/6 6:04:17
ASCII 代表美国信息交换标准代码。共有 128 个标准 ASCII 码,每个码都可以用一个 7 位二进制数表示:0000000 到 1111111。
如果尝试将字符存储为整数值,则会存储相应字符的 ASCII 值。
示例
import java.util.Scanner;
public class ASCIIValue {
public static void main(String args[]){
System.out.println("Enter a character ::");
Scanner sc = new Scanner(System.in);
char ch = sc.next().charAt(0);
int asciiValue = ch;
System.out.println("ASCII value of the given character is ::"+asciiValue);
}
}
输出
Enter a character :: e ASCII value of the given character is ::101

