for (Initialization statement,Conditional statement,Update) {
//Iterative processing
}
,
), but the types must be the same.&& etc.
),
), and method calls are also OKwhile (control statement);
ends with a semicolon (;
) at the end.
do {
... //Iterative processing
} while(Control statement);
{}
)In the case of a while
statement, only one statement is subject to repetition.
(The ʻifstatement feels the same.) (If you write the following process using IDE, it will shift the indent, so it seems to be correct.) (Not one line, one sentence. Up to
;`.)
int param = 0;
while (param < 3)
System.out.println("param:" + param);
param++;
Is the execution result
param:0
param:0
param:0
・ ・ ・
It becomes an infinite loop.
↓ is a compilation error.
do
System.out.println("param:" + param);
param++;
while(param < 3);
Recommended Posts