Suppose I have an input of six integers separated by spaces.
2 7 10 34 2 11
If I want to pick up into six variables int a,b,c,d,e,f;
.
In C
I can do it like the following directly
scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
In Java,the methods (that I know) I really irritating,as far as to me.You have to either use
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Then we can use String s=br.readLine();
and then s.split(" ")
to pick individual values.Another alternative is to use scanner
which does the same.Command-line arguments provides some relief but we cannot use it during runtime.
I want to ask isn't there any direct one line method to pick these space-seperated integers?
(There is a similar titled question but its the basic and off-topic so I raised this question) (There