Java tutorial
import java.math.BigDecimal; public class Main { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("235.000"); BigDecimal bg2 = new BigDecimal("23500"); // assign the result of stripTrailingZeros method to bg3, bg4 BigDecimal bg3 = bg1.stripTrailingZeros(); BigDecimal bg4 = bg2.stripTrailingZeros(); String str1 = bg1 + " after removing trailing zeros " + bg3; String str2 = bg2 + " after removing trailing zeros " + bg4; // print bg3, bg4 values System.out.println(str1); System.out.println(str2); } }