用条件结构语句判断某年份是否为闰年(打印输出以2020年为例)。
class Untitled {
static boolean isleap(int y)
{
return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0));
}
public static void main(String[] args) {
if (isleap(2020))
System.out.println("是");
else
System.out.println("不是");
}
}
是