扩展赋值运算符

扩展赋值运算符

package operator;
public class demo05 {
    public static void main(String[] args) {
        int a = 10;
        int b =20;
        a +=b; // a = a + b
        a -=b; // a = a - b
        System.out.println(a);

        //字符串连接符 + ,String
        System.out.println(a + b + ""); // 输出30
        System.out.println("" + a + b); // 输出1020,先转为String再进行后面的运算
    }
}
posted @ 2023-02-03 16:50  chengh0618  阅读(13)  评论(0编辑  收藏  举报