Its surprising that after reading almost the whole book, . . . Guys Is there any simplest way to get the input in java, such that I can add 2 strings, numbers by taking command line input from user.
There is only one way I know,
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
This clicks me as somewhat odd way of taking input. Guys I have recently moved from C/C++ to Java, and I was expecting the input taking mechanism to be butterly simple, but the above statement horrified me badly. We learn in 2-3rd chapter in C/C++ "How to take input" and in Java why is it such lately introduced in almost all the books?
Lord don't move that mountain, Give me the strength to climb it.
There are millions of ways of getting input. For input from the command line you could use the commandline arguments (main(String args), your approach but I would recommend you to look at the Console class which was introduced in java 6.
1 trapdoor: not all environments can supply a Console, for instance the Netbeans IDE.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
When you do things right, people won't be sure you've done anything at all.
Joined: Nov 30, 2009
Thanks for replies man, but in general Java books, why they are covered way after traversal of key concepts, thats still unknown to my limited intelligence.
thanks again, scanner one is really a cool one!