N Sahni wrote:Here is the sample code for getting user input in Java through command-line: . . .
But you didn't close the Readers.
Which is a good thing in this case. Closing the Readers would close System.in which will cause it to become useless within the entire JVM until it exits.
Just saw that readLine() can take a prompt. So this is N Sahni's example in Java 6.
Of course, you could make it shorter by in-lining the expression for value, at a slight cost to readability.