扩展赋值运算符和字符连接串
时间:2021-09-15 17:44:27
收藏:0
阅读:45
扩展赋值运算符和字符连接串
package operator;
public class Demo07 {
public static void main(String []args){
int a=10;
int b=20;
a+=b; //a=a+b
System.out.println(a);// 30
a-=b; //a=a-b
System.out.println(a);// 10
//字符串连接符 只要再 + 两侧出现字符串类型(String)它会把这个括号内的其他操作都转换为String类型进行连接
System.out.println(a+b); //30
System.out.println(""+a+b); //1020
System.out.println(a+b+""); //30
}
}
原文:https://www.cnblogs.com/yahhh/p/15265451.html
评论(0)