posted 14 years ago
Careful - if you create the BufferedReader inside the while loop, it will be susceptible to GC when (if) the loop repeats. This usually means the system will call close() on the BufferedReader, which will close() the InputStreamReader, which will then close() System.in. This will probably end your program, or at least make it impossible to enter any more numbers. I'd declare the BufferedReader as a static class variable, so it won't be accidentally GC'ed while your program is still running.