BigDecimal receives the value of a string

0

I have the following question, how can I sum a BigDecimal with a String .

String a = "8";
BigDecimal b = new BigDecimal(2);

Would it be something like this? b.add(a);

Note: I need the logic to be this, I just need to know how to assign the value of a BigDecimal of a variable String .

    
asked by anonymous 29.10.2017 / 21:33

1 answer

5
String a = "8";
BigDecimal a2 = new BigDecimal(a);
BigDecimal b = new BigDecimal(2);
BigDecimal c = b.add(a2);
    
29.10.2017 / 23:28