Java Learning Made Easy by Dheeraj Mehrotra - HTML preview
PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.
Download the book in PDF, ePub, Kindle for a complete version.
FOR LOOP IN JAVA



This acts as an automatic looping statement with all the control

elements/conditions placed in one place. It is equivalent to the

FOR/NEXT of BASIC high-level language.


It has the following format :


for (initialization expression;testexpression;update expression) {

loop body
}



It starts with the keyword for, followed by parentheses that contains
three expressions separated by semicolons. eg.for (s=1;j<11;j++)




The above segment assigns the loop variable s by 1, the test condition


is j<11 and the increment expression is j++. The loop executes for 10

times, with the value of s ranging from 1 to 10.









attention@computerscienceexpertise.com


















