-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
  • 8

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
  • 1,928
  • 1
  • 16
  • 26