- Java.math package classes
- Java.math - Home
- Java.math - BigDecimal
- Java.math - BigInteger
- Java.math - MathContext
- Java.math package extras
- Java.math - Enumerations
- Java.math - Discussion
Java.math.BigDecimal.plus() Method
Description
The java.math.BigDecimal.plus() returns a BigDecimal whose value is (+this), and whose scale is this.scale().
This method, which simply returns this BigDecimal is included for symmetry with the unary minus method negate().
Declaration
Following is the declaration for java.math.BigDecimal.plus() method.
public BigDecimal plus()
Parameters
NA
Return Value
This method returns the object value i.e this.
Exception
NA
Example
The following example shows the usage of math.BigDecimal.plus() method.
package com.tutorialspoint; 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 ); } }
Let us compile and run the above program, this will produce the following result −
The value of the BigDecimal is -123.126
java_math_bigdecimal.htm
Advertisements
To Continue Learning Please Login
Login with Google