A program that I write recives an input like this
W 12.1 -1 2.2
B 1.2 3.2 1
And I need to check if the numbers are within coonstraints, so my idea is to store those numbers in array as integers. The numbers needs to be separated by the white spaces and the dots. Currently I have this code:
public static void main(String[] args) {
Scanner reader = new Scanner (System.in);
String input = reader.nextLine();
String[] numbers = input.substring(2,input.length()).split("\\.");
System.out.println(Arrays.toString(numbers));
}
For input W 12.1 -1 2.2
the output is [12, 1 -1 2, 2]
As you see I managed to make it deal with the dots but I can't remove the white spaces. What is the most resource efficient way to achieve my task ?