字符连接符 +、
1.对于+运算符的两侧,只要有一方出现字符串类型,就会把+号的其它操作数都变成string
细节:字符串影响+连接符后面,但不影响前面,前面依旧进行运算
int a=10;
int b=20;
System.out.println(""+a+b);
System.out.println(a+b+"");
package operator;
public class Demo07 {
public static void main(String[] args) {
int a=10;
int b=20;
a+=b;
a-=b;
System.out.println(a);
System.out.println(a+b);
System.out.println(""+a+b);
System.out.println(""+a+b);
System.out.println(a+b+"");
}
}
x ?y:z
如果x==true,则结果为y,
否则结果为z
package operator;
public class Demo08
{
public static void main(String[] args) {
int score =50;
String type = score <60?"不及格":"及格";
System.out.println(type);
}
}