Java for loop
Java for loop is a definite loop which iterates a piece of block continuously until the condition is met or infinite.
Class Level lock can be achieved by using two keywords static and synchronized in any method signature. But Object level lock can be achieved by using synchronized keyword or block, there can be multiple Objects for a particular class but only one class will be available for any Java application with unique name.
for loop example
public class ForLoopExample { public static void main(String[] args) { for(int i=1;i<=5;i++) { System.out.println("Loop iterating "+i+" Times"); } } }
In the above example, if we see the loop will be iterated 5 times and subsequently it prints 5 times the above SOP statement.
Output :-Loop iterating 1 Times Loop iterating 2 Times Loop iterating 3 Times Loop iterating 4 Times Loop iterating 5 Times