Write Java program to Implement infinite loop using do-while loop


This Java program is 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 do-while loop ensures that the code block inside the loop will execute at least once, and then the loop will continue to execute indefinitely.

This program will continue to run until it is forcefully terminated, such as by manually stopping the program or shutting down the computer. 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_DoWhile
{
	public static void main(String[] args)
	{
		do
		{
			System.out.println("Java");
		}while(true);
	}
}

Output

Java
Java
Java
Java
Java
Java
.
.
.
Infinite

Example Programs