/**
* 条件运算符(或叫三元运算符
* 格式(x?y:z)如果x为true时返回y反之返回z
* @author aflft
*
*/
public class TestOperator06 {
public static void main(String[] args) {
int a=80;
int b=-100;
String type=a<60?"不及格":"及格";
System.out.println(type);//可代替简单if语句
System.out.println(b>0?1:(b==0?0:-1));
}
}
« 数据类型的转化
|
字符串连接符»
|