Write Java program to Implement infinite loop using while loop


This Java program is also an example of an infinite loop that prints the word "Java" continuously. The loop condition while(true) always evaluates to true, meaning the loop will never exit. The program will continue to execute indefinitely until it is forcefully terminated.

As with the previous example of an infinite loop using a do-while loop, 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_While
{
	public static void main(String[] args)
	{
		while(true)
		{
			System.out.println("Java");
		}
	}
}

Output

Java
Java
Java
Java
Java
Java
.
.
.
Infinite

Example Programs