-1

Scanner.next() return a string that contains a string "10,5".

How could I get these 2 int values into 2 different int variables?

gg123
  • 31
  • 9

1 Answers1

0

Solution using Java 8:

String data = "10,5";
int[] numbers = Arrays.asList(data.split(",")).stream()
                      .map(String::trim)
                      .mapToInt(Integer::parseInt).toArray();
uneq95
  • 2,158
  • 2
  • 17
  • 28