function of for loop in java
Answers
Answered by
1
An already declared variable can be used or a variable can be declared, local to loop only. Testing Condition: It is used for testing the exit condition for a loop. It must returna boolean value. It is also an Entry Control Loop as the condition is checked prior to the execution of the loop statements.
bathinitopogula:
not to the point
Answered by
0
For-loop is the most common type of iterative statement in java. It is used to repeat a set-of-statements depending upon a condition test. It is a entry-controlled loop, i.e., the condition is checked before entering the body-of-loop.
Example- Consider the following code-
class Test
{
void main( )
{
for(int i=0; i<5; i++)
{
System.out.println(i);
}
}
}
The above loop prints 'i' until the result of the test expression is true. The value of 'i' keeps on incrementing with every loop and it ends as soon as the value of 'i' reaches 5. Following is the output of the above code-
1
2
3
4
Thank You:)
Similar questions
Computer Science,
7 months ago
Computer Science,
7 months ago
Geography,
7 months ago
Math,
1 year ago
Science,
1 year ago