Home arrow Java arrow Page 6 - Java Part 2: Syntax
JAVA

Java Part 2: Syntax


In this, part two of this ten part series on Java, Chris looks at the Java language syntax, variable declerations, truth conditions, loops and more. He finishes by wrapping everything up into a simple Java function.

Author Info:
By: Chris Noack
Rating: 5 stars5 stars5 stars5 stars5 stars / 9
November 27, 2001
TABLE OF CONTENTS:
  1. · Java Part 2: Syntax
  2. · Decleration and assignment
  3. · Making code more readable
  4. · Truth operations
  5. · Iterations and looping
  6. · The while loop
  7. · Putting it all together
  8. · Conclusion

print this article
SEARCH DEVARTICLES

Java Part 2: Syntax - The while loop
(Page 6 of 8 )

The while loop is similar in action to the for loop, but different in grammar. They can always be interchanged. For example, the following while loop will iterate through the values of i until the truth test fails.

int i = 0;

while( i < 100)

{

// perform some action;

i++;

}


as with the for loop, we can construct an infinite loop. Such a loop would look like this:

while( TRUE )

{

// perform some action

}


Notice the indentation between the braces.

The do...while loop

The do...while loop is the same as a while loop, except that the body of the code will always be executed at least once.

do

{

// perform some action

} while( truth statement );



blog comments powered by Disqus
JAVA ARTICLES

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials