How can I get two numbers that are written in a single line - is there a Split() method?
I want to ask the user for input in console. He'll be writing down two numbers separated by a single space.
In Java is there something like the C# Split() method I can use?
开发者_高级运维Thank you!
Yes, there is: String.split. Note that it takes a regex as the parameter though. Alternatively you could use a StringTokenizer
or a Scanner
.
There is a split() method in String class.
String.split();
精彩评论