Can a for statement loop indefinitely?

India
April 27, 2007 3:19am CST
asked in my interview.
2 responses
• Egypt
8 May 07
the for loop is the same as while loop, all the difference that it encapsulates some statements in one statement. //initialization while(condition) { //update } for(//initialization;//condition;//update) {}
@raghwagh (1527)
• India
28 Apr 07
Why not? Try this public class tm { public static void main(String args[]) { for(int i=0;;i++) { System.out.print(i); } } } Making the loop infinite is based on the condition you give.