字符串连接符 +

10+20=30;
" “+10+20=1020;
10+20+” "=30;

public class demo5 {
    
    
    public static void main(String[] args) {
    
    
    int a = 10;
    int b = 20;

        System.out.println(a+b);

        //字符串连接符 +
        System.out.println(""+a+b);
        System.out.println(a+b+"");
    }
}

当" “在数字运算的前边时,后边的数字运算会按照字符串的形式相加
当” "在数字的末尾时,输出结果虽然仍是字符串型,但输出的是a+b的运算结果

运行结果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_45361567/article/details/112602127