原来的问题是这样的.
public class test {
public static void main(String[] args){
int i = '1' + '2' + '3' + "";
System.out.println(i);
}
}
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from String to int
Run Code Online (Sandbox Code Playgroud)
然后我改变了这样的代码:
public class test {
public static void main(String[] args){
int i = '1' + '2' + '3';
System.out.println(i);
}
}
Run Code Online (Sandbox Code Playgroud)
输出是150.
但是当我写这样的代码时:
public class test {
public static void main(String[] args){
System.out.println('a'+'b'+'c'+"");
}
}
Run Code Online (Sandbox Code Playgroud)
输出变为294.
我想知道为什么.
java ×1