Online Java Compiler By
JavaTpoint.com
import java.math.BigInteger; public class BigIntegerLongValueExample { public static void main(String[] args){ // create 4 BigIntegerobjects BigInteger big1,big2,big3,big4; // create 4 longobjects long long1,long2,long3,long4; // assign values to big1,big2,big3,big4 big1= new BigInteger("123"); big2= new BigInteger("-123"); big3= new BigInteger("12345678901234567890"); big4= new BigInteger("-12345678901234567890"); // assign long value of big1,big2,big3,big4 to long1 ,long2,long3 ,long4 long1= big1.longValue(); long2= big2.longValue(); long3= big3.longValue(); long4= big4.longValue(); String str1= "Result of longValueoperation on " + big1 +" is " + long1; String str2= "Result of longValueoperation on " + big2 +" is " + long2; String str3= "Result of longValueoperation on " + big3 +" is " + long3; String str4= "Result of longValueoperation on " + big4 +" is " + long4; // print long1,long2,long3,long4 values System.out.println(str1); System.out.println(str2); System.out.println(str3); System.out.println(str4); } }
Output