当前位置: 技术问答>java相关
我是学pb的,判断闰年的是isdate("2-28"),但在java里怎么判断呢?
来源: 互联网 发布时间:2015-02-02
本文导语: | public class LeapYear{ public static void main( String args[] ){ int year=1989; //method 1 if( (year%4==0 && year%100!=0) || (year%400==0) ) System.out.println(year+" is a leap year."); else System.out.println(year+" is not a leap year.");
|
public class LeapYear{
public static void main( String args[] ){
int year=1989; //method 1
if( (year%4==0 && year%100!=0) || (year%400==0) )
System.out.println(year+" is a leap year.");
else
System.out.println(year+" is not a leap year.");
public static void main( String args[] ){
int year=1989; //method 1
if( (year%4==0 && year%100!=0) || (year%400==0) )
System.out.println(year+" is a leap year.");
else
System.out.println(year+" is not a leap year.");