字符串连接符“+”的应用区别
public class Demo11 {
public static void main(String[] args) {
int a = 10;
int b = 20;
a = a+b;
System.out.println(a);
System.out.println("================");
//字符串连接符“+”的应用区别
//""在前,则后面的a、b均转化为String类型;
System.out.println(" "+a+b);
//若a+b在前,则计算a+b。
System.out.println(a+b+"");
//""在中间,则a、b均转化为String类型;
System.out.println(a+" "+b);
System.out.println(a+""+b);
}
}
输出:
30
================
3020
50
30 20
3020
Process finished with exit code 0
浙公网安备 33010602011771号