Java
  Home arrow Java arrow Page 4 - Java Statements
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Java Statements
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2007-10-24

    Table of Contents:
  • Java Statements
  • While Loop
  • Do-While
  • For Loop
  • To Be Continued...

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Java Statements - For Loop


    (Page 4 of 5 )

    The For Loop allows you to condense the code used in While loops. If we wanted to rewrite our NASA launch code with a For loop, it would look something like this (hit it!):

    (Note: the writer of this article has listened to the Beastie Boys one too many times)


    class LaunchCode {

    public static void main(String args[]) {

    int timer;


    for(timer = 10; timer > 0; timer—)

    System.out.println(“T minus “ + timer);

    }

    }

    This would result in the same countdown as our previous NASA program. As a side note, you could technically initialize the timer variable inside the For loop. If you had done so, you would not be able to call it outside of the loop. Placing the variable outside the loop allows the variable to be called again later on.

    Jump Statements

    There are three types of Jump statements in Java: the break, the continue, and the return. We have already used the break statement in some of our previous code. It's function is pretty simple: it terminates a statement, exits a loop, or can be used as a goto statement. Since we have already used it several times, I won't discuss it any further. 

    More Java Articles
    More By James Payne


       · This article discusses Java Statements, like the If statement and Loops (such as the...
     

       

    JAVA ARTICLES

    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway