java中bigdecimal初始化的有哪些方法
在Java中,可使用以下几种方法对BigDecimal对象进行初始化:
BigDecimal bigDecimal1 = new BigDecimal("10.5");
BigDecimal bigDecimal2 = new BigDecimal(10.5);
BigDecimal bigDecimal3 = BigDecimal.valueOf(10L);
BigInteger bigInteger = new BigInteger("10");
BigDecimal bigDecimal4 = new BigDecimal(bigInteger);
这些是经常使用的BigDecimal初始化方法,可以根据具体的需求选择适合的方法进行初始化。
TOP