public class LeapYear {
public static void main(String[] args) {
// TODO Auto-generated method stub
int year = Integer.parseInt(args[0]);
boolean isLeapYear;
isLeapYear = (year % 4 == 0); //年份要先被四整除
isLeapYear = isLeapYear && (year % 100 != 0); //接着,若年份不是整百年份,则为闰年;若能被100整除,则先令isLeapYear的值设为false
isLeapYear = isLeapYear || (year % 400 == 0); //因为此时isLeapYear为false,只有当年份能被400整除时,isLeapYear的值才能为true,即闰年
System.out.println(isLeapYear);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int year = Integer.parseInt(args[0]);
boolean isLeapYear;
isLeapYear = (year % 4 == 0); //年份要先被四整除
isLeapYear = isLeapYear && (year % 100 != 0); //接着,若年份不是整百年份,则为闰年;若能被100整除,则先令isLeapYear的值设为false
isLeapYear = isLeapYear || (year % 400 == 0); //因为此时isLeapYear为false,只有当年份能被400整除时,isLeapYear的值才能为true,即闰年
System.out.println(isLeapYear);
}
}