java三目运算能这样写吗?
return((year%4 ==0|| year%100 != 0 && year%400 == 0 )?System.out.print("闰年"):System.out.print("平年"));
如果要判断输出为闰年或平年,能直接在三目运算中写吗?
return((year%4 ==0|| year%100 != 0 && year%400 == 0 )?System.out.print("闰年"):System.out.print("平年"));
如果要判断输出为闰年或平年,能直接在三目运算中写吗?
三目是 c = condition ? a : b
condition == true 那么 c = a
condition == false 那么 c = b
long year=2004;
System.out.println( ((year%4 ==0 && year%100 != 0) || year%400 == 0 )? "闰年":"平年"); }