为什么 ('1'+'1') 在 Java 中输出 98?
2022-09-03 09:47:50
我有以下代码:
class Example{
public static void main(String args[]){
System.out.println('1'+'1');
}
}
为什么它输出?98
我有以下代码:
class Example{
public static void main(String args[]){
System.out.println('1'+'1');
}
}
为什么它输出?98
'1'
是一个文本,两个 s 之间的运算符返回一个 .该字符的 unicode 值为 49,因此当您添加其中的两个字符时,您将获得 98。char
+
char
int
'1'