标题日期:2020/1/14
标题IDE:Intellij IDEA
标题功能:判断是否是闰年
package test.demo;
public class LeapYear {
int year,month,day;
public LeapYear(int year,int month,int day){
this.year = year;
this.month = month;
this.day = day;
}
public void print(){
System.out.print("日期:"+year+'年'+month+'月'+day+'日');
}
public Boolean isLeapYear(int year){
return (year%400==0)||(year%4==0&&year%100!=0);
}
public static void main(String[] args){
LeapYear leapYear = new LeapYear(2012,12,25);
if(leapYear.isLeapYear(leapYear.year)){
leapYear.print();
System.out.println("是闰年");
}
else{
leapYear.print();
System.out.println("不是闰年");
}
}
}