how to get i/p seperated by space?
eg 3423 43234
can u give me the syntax for doing so?
created
last reply
- 1
reply
- 170
views
- 2
users
how to get i/p seperated by space?
eg 3423 43234
can u give me the syntax for doing so?
If theres not much input, you can just use a Scanner (sc), and use sc.nextInt(), int.
If theres a lot of input, thats far too slow, so I use a BufferedReader (br), and then split() the string. For example,
String[] inputParts = br.readLine().trim().split("\\s++");
where that regular expression means 'one or more whitespace'.
Topic | Category | Replies | Views | Activity |
---|---|---|---|---|
Strategies for Tackling Java-Based SPOJ Problems More Efficiently? | JAVA based languages | 0 | 63 | May 23 |