Write Java program to Implement infinite loop using for loop


This Java program is yet another example of an infinite loop that prints the word "Java" continuously. In this case, the loop header for(;;) does not include any initialization, condition or update expressions, which means that the loop will execute indefinitely. The program will continue to execute until it is forcefully terminated.

As with the previous examples of infinite loops using while and do-while loops, it is important to avoid writing infinite loops in programs, as they can cause the program to crash or consume excessive resources.

Source Code

public class Infinite_For
{
	public static void main(String[] args)
	{
		for(;;)
		{
			System.out.println("Java");
		}
	}
}

Output

Java
Java
Java
Java
Java
Java
.
.
.
Infinite

Example Programs