The Meaning of above is every 4 year’s the Leap Year comes and when the Centuries comes into pictures it will divided by the 400 so that the remainder should be zero is the Leap year.
How to get a Leap Year in Java Example
import java.util.Calendar.*; import java.lang.*; //its’ a default package which will import class LeapYear { public static void main(String args[]) throws Exception { Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) { System.out.println("Leap Year"); } else { System.out.println("Not a Leap Year); } } }
0 comments:
Post a Comment