difference between infinite and empty loop in Java
Answers
Answered by
36
An empty loop is a loop that doesn't contain any executable statement, whereas, an infinite loop is a loop that runs an infinite number of times.
Aratrika03:
thank-you so much
Answered by
32
An empty loop contain only one empty statement.They are mostly used to produce time breaks.
Ex-for(int a=0;a<10;a++)
;
It may also be written as-
for(int a=0;a<10;a++);
An infinite loop on the other hand continues forever.
Ex-for(int a= 10; ;)
...Other statements
or
for(int a=10;a>1;;)
...Other statement
Ex-for(int a=0;a<10;a++)
;
It may also be written as-
for(int a=0;a<10;a++);
An infinite loop on the other hand continues forever.
Ex-for(int a= 10; ;)
...Other statements
or
for(int a=10;a>1;;)
...Other statement
Similar questions