public class Test1{
public boolean isLeapYear(int year) {
if((year%4==0 && year%100!=0) || (year%400==0)){System.out.println("这是闰年");
return true;}
else {System.out.println("这是平年");
return false;}
}
public static void main(String[] args) {
Test1 test1=new Test1();
test1.isLeapYear(2000);
}
}
写一个方法判断某一年是否为闰年。 标准:1) 能被4整除,但不能被100整除;或 能被400整除;
猜你喜欢
转载自blog.csdn.net/weixin_42428664/article/details/81809010
今日推荐
周排行