Java Math BigInteger.negate() 方法


Java Math BigInteger.negate() 方法

package com.codingdict;



import java.math.*;



public class BigIntegerDemo {



   public static void main(String[] args) {



      // create 2 BigInteger objects

      BigInteger bi1, bi2;



      bi1 = new BigInteger("20");



      // assign negate value of bi1 to bi2

      bi2 = bi1.negate();



      String str = "Negated value of " + bi1 + " is " +bi2;



      // print bi2 value

      System.out.println( str );

   }

}