Convert String array to List<BigDecimal>

Advertisements
String[] nums = {"0", "-1.1", "2.0"};

List<Double> decimals = Arrays.stream(nums)
        .map(Double::parseDouble)
        .collect(Collectors.toList());

List<BigDecimal> bigDecimals = ?

Is there a similar easy way to convert decimals in String[] to List of BigDecimals

>Solution :

Replace Double::parseDouble with BigDecimal::new.

Leave a ReplyCancel reply