public class example6
{
public static void main(String args[])
{
int total = 10;
total = (total > 5) ? total + 1 : total * 2;
System.out.println("total = " + total);
int x = 10;
System.out.println(x + ((x % 2 == 0) ? " is even" : " is odd"));
//注意 一个println里面不能有两个引号
}
}
example4-5 Conditional Operator
最新推荐文章于 2021-06-28 22:43:44 发布