6
I am trying to add a value in a variable of type Bigdecimal, however independent of the calculation it results in 0.
Sample code:
BigDecimal valorTotal = new BigDecimal(0);
public void adicionarVenda(int idProduto, int quantidade) {
BigDecimal newQtd = new BigDecimal(quantidade);
BigDecimal newQtd2 = newQtd.multiply(preco);
valorTotal.add(newQtd2);
System.out.println(valorTotal);
}
What is the value of
preco
that you used?– Lucas Lima
The price is in Bigdecimal
– Luan R