gpt4 book ai didi

java - 打印 char 类型没有任何结果

转载 作者:行者123 更新时间:2023-11-29 07:32:51 35 4
gpt4 key购买 nike

我正在学习 Java 认证。在我正在阅读的书中,有一行是这样写的:

char c = 65;
System.out.println(c); //Prints "A"

在下一个示例中,这一行:

char seven = 7; //number, cause it's not in single quotes
System.out.println(seven); // doesn't print anything

我不明白为什么。有人可以解释一下吗?

最佳答案

char类型是UTF-16字符编码单元,整型是字符编码。对于 ASCII,65 是 A,7 是 BEL(或 BELL),其中不打印任何内容,但会发出声音。来自 here :

Bell character is the control code used to sound an audible bell or tone in order to alert the user (ASCII 7, EBCDIC 2F). Bell character is an ASCII control character, code 7 (^G). When it is sent to a printer or a terminal, nothing is printed, but an audible signal is emitted instead.

您还可以查看 ASCII 表 here .

关于java - 打印 char 类型没有任何结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39683277/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com