How do i use separate two integers using dot in java?
This question already has an answer here:
If you want it in the same line use: s.next()
.
If you want the text in the next line you need to do: s.nextLine()
Whatever method you use it will return a java.lang.String
.
You can use String[] numbers = yourString.split(".")
The array what you get if you split the string you can get all numbers:
int x = Integer.valueOf(numbers[0]);
int y = Integer.valueOf(numbers[1]);
int z = Integer.valueOf(numbers[2]);
//Dont forget it can throw a NumberFormatException if the current String is not a valid number.
链接地址: http://www.djcxy.com/p/78340.html
下一篇: 我如何在java中使用单独的两个整数?