Skip to Content
Real World XML
book

Real World XML

by Steven Holzner
January 2003
Beginner to intermediate content levelBeginner to intermediate
1200 pages
23h 42m
English
Peachpit Press
Content preview from Real World XML

Java Loops: for, while, do…while

The next step after working with conditional statements is to handle loops. Like JavaScript, Java supports a for loop, a while loop, and a do...while loop.

Here's how you use a Java for loop in general, Note that the statement that makes up the body of the for loop can be a compound statement; it can be made up of several single statements enclosed in curly braces:

for (initialization_expression;
					end_conditon;
					iteration_expression) {
    statement
}

You place an expression in the initialization part of the for loop (which often initializes a variable—that is, a loop index—to 0), and then you place a test condition in the test part of the loop that is tested each time the code in the loop executes. If the test is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Inside XML

Inside XML

Steven Holzner
XML Hacks

XML Hacks

Michael Fitzgerald

Publisher Resources

ISBN: 0735712867Purchase book