Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Listing out leap years between certain period

In this section, you will learn how to finding and listing out the leap years between two years.

Tutorial Details:

In the following example we have to find out the leap years between 1990 and 2006. First define the two years under a class "leapyears". Let i = 2006 and n=1990. Now with the help of for loop method initialize the year as n=1990 and n<=i. Also apply the increment statement in the loop as we have to check one by one.

As we know a leap year is divisible by 4, define an integer l=n%4. So if 'n' is divisible by 4 or l=0, then the particular year can be a leap year. For checking this, apply the if statement and if this satisfies then, the year will be a leap year. For listing out each year write "+n" in the System.out.println.


 

Rate Tutorial:
http://www.roseindia.net/java/beginners/leapyears.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Listing out leap years between certain period

View Tutorial:
Listing out leap years between certain period

Related Tutorials:

Program your Palm in Java, Part 1: The PalmOS Emulator - JavaWorld November 1999
Program your Palm in Java, Part 1: The PalmOS Emulator - JavaWorld November 1999
 
One, two, three, or n tiers? - JavaWorld January 2000
One, two, three, or n tiers? - JavaWorld January 2000
 
Program your Palm in Java, Part 1: The PalmOS Emulator - JavaWorld November 1999
Program your Palm in Java, Part 1: The PalmOS Emulator - JavaWorld November 1999
 
Script JavaBeans with the Bean Scripting Framework - JavaWorld March 2000
Script JavaBeans with the Bean Scripting Framework - JavaWorld March 2000
 
Sun lets Jini Starter Kit 1.1 out of the bottle - JavaWorld December 2000
Sun lets Jini Starter Kit 1.1 out of the bottle - JavaWorld December 2000
 
When is a Singleton not a Singleton? - JavaWorld January 2001
When is a Singleton not a Singleton? - JavaWorld January 2001
 
Construct secure networked applications with certificates, Part 1 - JavaWorld January 2001
Construct secure networked applications with certificates, Part 1 - JavaWorld January 2001
 
Warning! Threading in a multiprocessor world - JavaWorld February 2001
Warning! Threading in a multiprocessor world - JavaWorld February 2001
 
Can double-checked locking be fixed? - JavaWorld May 2001
Can double-checked locking be fixed? - JavaWorld May 2001
 
Secure your Java apps from end to end, Part 1 - JavaWorld June 2001
Secure your Java apps from end to end, Part 1 - JavaWorld June 2001
 
Generate JavaBean classes dynamically with XSLT
Generate JavaBean classes dynamically with XSLT
 
Listen to heartbeats using JMS
Listen to heartbeats using JMS
 
Publish
Publish event-driven Web content with JSP custom tags
 
Achieve strong performance with threads, Part 2
Achieve strong performance with threads, Part 2
 
Create client-side user interfaces in HTML, Part 2
Create client-side user interfaces in HTML, Part 2
 
To my mind, of few interest
To my mind, of few interest
 
Introducory article
Introducory article
 
CalendarComponent
Java Calendar Component V 1.0
 
Running Lucene Search on WebLogic Portal 8.1
Lucene comes with two main services available: indexing and searching. The indexing tasks are done independently from the search tasks. Both the index and search services are available so that developers can extend them to meet their needs.
 
Domain Registration Guide
Domain Registration Guide Domain Registration Guide What is Domain? Internet is the large network of computers. On the Internet there should be some way to identify the computers. Domain name is the solution for this. Domain Name is the unique
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.