集册 Java实例教程 确定年份是否为闰年

确定年份是否为闰年

欢马劈雪     最近更新时间:2020-01-02 10:19:05

475
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
确定年份是否为闰年


public class Main {

 

        public static void main(String[] args) {/**时   代    Java - nowjava.com**/

                int year = 2004;

               

                if((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))

                        System.out.println("Year " + year + " is a leap year");

                else

                        System.out.println("Year " + year + " is not a leap year");

        }

}