How to get a Leap Year



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);      }

}

}  // The Meaning of above is every 4 year’s the LeapYear comes and when The Centuries comes into pictures it will divided by the 400 so that the remainder should be zera is the Leap year

Random Posts

  • Define Precompile of Jsp page
  • Difference between session.save() and session.saveOrUpdate()
  • What the web.xml file can do
  • What is JRE ? Explain
  • Explain executeQuery Method

Post a Comment