Infinite Loop In Java Example
Chapter:
Control Statements
Last Updated:
15-07-2016 10:09:26 UTC
Program:
/* ............... START ............... */
public class JavaInfiniteLoopExample {
public static void main(String[] args) {
for (;;)
System.out.println("Hello");
/*
* To terminate this program press ctrl + c in the console.
*/
}
}
/* ............... END ............... */
Output
Hello
Hello
Hello
Hello
..
..
Notes:
-
An infinite loop occurs when a condition always evaluates to true. Usually, this is an error.
- Loop can be made infinite as long as you make a way to never hit the exit conditions.
Tags
Infinite Loop, Java