import java.util.Scanner; public class IfYears { public static boolean isleapyear(int year){ if((year%4==0&&year%100!=0)||year%400==0) return true; else return false; } public static void main(String[] args) { System.out.println("请输入要判断的年份: "); Scanner in = new Scanner(System.in); int n = in.nextInt(); if(isleapyear(n)==true) { System.out.println(n+"年为闰年"); } else System.out.println(n+"年不是闰年"); } }