Aakash Goel wrote:
Yeah, it does work instantaneously.
great
What I mean to say is that,
When I compared it with a C program I wrote for the same job [just taking inputs], it was comparatively slower [took approximately twice the time].
So, is there a faster way?
1) I know of no faster way, though that doesn't mean it doesn't exist.
2) If we're discussing getting input from a user sitting at a console, this smells of a micro-optimization non-issue since the speed of the Scanner's interactions is measured in milliseconds, while the speed of the user entering data is measured in seconds. Speeding up the scanner even by 50% or more will not change any of the perceived characteristics of the program. Again, I have a feeling that there's more about this issue than you have yet told us.