Java Math Bigdecimal Equals


Java Math Bigdecimal Equals

package com.codingdict;



import java.math.*;



public class BigDecimalDemo {



   public static void main(String[] args) {



      // create 3 BigDecimal objects

      BigDecimal bg1, bg2, bg3;



      bg1 = new BigDecimal("235.00");

      bg2 = new BigDecimal("235.00");

      bg3 = new BigDecimal("235");



      // create 2 boolean objects

      Boolean b1,b2;



      // assign the result of equals method to b1, b2

      b1 = bg1.equals(bg2);

      b2 = bg1.equals(bg3);



      String str1 = bg1 + " equals " + bg2 + " is " +b1;

      String str2 = bg1 + " equals " + bg3 + " is " +b2;



      // print b1, b2 values

      System.out.println( str1 );

      System.out.println( str2 );

   }

}