下面的程序将打印出什么呢?
public class LastLaugh{
public static void main(String[] args){
System.out.print("H"+"a");
System.out.print('H'+'a');
}
}大家可以先想一下觉得是什么 然后再把这段代码跑一下看看最后结果
public class LastLaugh{
public static void main(String[] args){
System.out.print("H"+"a");
System.out.print('H'+'a');
}
}大家可以先想一下觉得是什么 然后再把这段代码跑一下看看最后结果
'H'+'a'会转作整型做加法因为string之间是定义了加法,字符之间没有定义这种加法
第二个应该是个数字吧
“+”号两边一边有字符串输出结果就是字符串,没有的话就是转成int计算