Java Math BigInteger.toString() 方法


Java Math BigInteger.toString() 方法

package com.codingdict;



import java.math.*;



public class BigIntegerDemo {



   public static void main(String[] args) {



      // create 2 BigInteger objects

      BigInteger bi1, bi2;



      // create 2 String objects

      String s1, s2;



      bi1 = new BigInteger("1234");

      bi2 = new BigInteger("-1234");



      // assign String value of bi1, bi2 to s1, s2

      s1 = bi1.toString();

      s2 = bi2.toString();



      String str1 = "String value of " + bi1 + " is " +s1;

      String str2 = "String value of " + bi2 + " is " +s2;



      // print s1, s2 values

      System.out.println( str1 );

      System.out.println( str2 );

   }

}