Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Java

Idiom #258 Convert list of strings to list of integers

Convert the string values from list a into a list of integers b.

import static java.lang.Integer.parseInt;
for (String s : a) b.add(parseInt(s));
import static java.util.Arrays.stream;
b = stream(s)
    .mapToInt(Integer::parseInt)
    .toArray();
b = a.stream()
    .map(Integer::parseInt)
    .toList();
System.Linq;
var b = a.Select(i => int.Parse(i)).ToList();

New implementation...