How to get list of Integer from String
java
Solution
You can use a `Scanner` to read the string one integer at a time.
Scanner scanner = new Scanner(number);
List<Integer> list = new ArrayList<Integer>();
while (scanner.hasNextInt()) {
list.add(scanner.nextInt());
}
Problem
my string contains `Integer` separated by space: ``` String number = "1 2 3 4 5 " ``` How I can get list of `Integer` from this string ?