Sunday, February 24, 2002 02:48 PM
>I have seen many author/programmer use infinite loop without a break to exit
This is because there are many author/programmer with bad habits.
Good C programmers are often bad Java programmers...often they fall in "legacy" bad practices, like this, or crypting coding etc.
(a file is wrapped inside a bufferedReader obj)
String s = aBufferedObj.readline( );
System.out.println (s); }
Only an exception, when the file ends, can break this loop. Generally it's better to check for the end of file, instead of causing an exception.
Never-ending loops have sense for daemon threads, or for processes that never end (like for example a shell program reading commands from the keyboard and executing it by the OS). In some occasions, this kind of loops are ok, but in most cases it's just a bad practice to avoid.