java.math.BigDecimal.plus() 返回一個BigDecimal,其值是 (+this),並且其刻度為是 this.scale().
這種方法,它只是返回此BigDecimal是包括對稱性與一元減號方法negate()。
以下是java.math.BigDecimal.plus()方法的宣告
public BigDecimal plus()
NA
此方法返回的物件的值即 this
NA
下面的例子顯示math.BigDecimal.plus()方法的用法
package com.yiibai; import java.math.*; public class BigDecimalDemo { public static void main(String[] args) { // create 2 BigDecimal Objects BigDecimal bg1, bg2; // assign value to bg1 bg1 = new BigDecimal("-123.126"); // assign the result of plus method on bg1 to bg2 bg2 = bg1.plus(); String str = "The value of the BigDecimal is " + bg2; // print the value of bg2 System.out.println( str ); } }
讓我們編譯和執行上面的程式,這將產生以下結果:
The value of the BigDecimal is -123.126