Write a program to accept initial value and final value for workers workship in for loop in static initialisation
Answers
Answered by
0
Answer:
Prerequisite: Loops in Java
The structure of basic for loop:
for(initialization; boolean expression; update statement)
{
//Body
}
Let’s look at some basic examples of using for loop and the common pitfalls in using for loop
Providing expression in for loop is must : For loop must consist a valid expression in the loop statement failing which can lead to an infinite loop. The statement
for ( ; ; )
is similar to
while(true)
// Java program to illustrate
// infinite loop
public class Example1
{
public static void main(String[] args)
{
for( ; ; )
{
System.out.println("This is an infinite loop");
}
}
}
Similar questions