This example will show how to create an infinite for loop , while and do while. Typically in error an infinite loop occurs when a condition always evaluates to true.
Infinite For Loop @Ignore ( "Infinite loop" )
@Test
public void infinite_for_loop () {
for (;;) {
}
}
Infinite While Loop @Ignore ( "Infinite loop" )
@Test
public void infinite_while_loop () {
while ( true ) {
}
}
Infinite Do While Loop @Ignore ( "Infinite loop" )
@Test
public void infinite_do_while_loop () {
do {
} while ( true );
}
Infinite loops posted by Justin Musgrove on 17 June 2014
Tagged: java and java-general
Share on: Facebook Google+
All the code on this page is available on github:
CreateInfiniteLoop.java