Implement BigInteger in Java
Java have a special feature called bigInteger which can be used when we need to use a integer which can't be adjust in long. below is an example of how to use bigInteger in java. in the example code i used 10 and 5 as the value of bigInteger but u can assign any integer value i repeat any integer value in place of it. there are no limitation in it like we have in int or long. import java.math.BigInteger; import java.util.Scanner; public class BigIntegerEx { public static void main(String[] args) { BigInteger a, b, c, sum, subtract, multiply, divide, abs, max, min; a = new BigInteger("10"); //declearing a bigInteger which value is 10 b = new BigInteger("5"); //declearing another bigInteger which value is 10 sum = a.add(b); //add a and b subtract = a.subtract(b); //subtract b form a multiply = a.multiply(b); //multiply a by b divide = a.divide(b); //divide a by b abs = (b.subtract(a)).abs(); //find the absolute value of (b-a) max = a.max(b); //find the maximum of a and b min = a.min(b); //find the minimum of a and b System.out.println("Sum = "+ sum + ", Subtract = "+ subtract + ", Multiply = "+ multiply + ", Divide = "+ divide + ", ABS = "+ abs + ", MAX = " + max + ", MIN = "+ min); //printing all the value we got Scanner sc = new Scanner(System.in); //create a scanner object to scan a biginteger value. c = sc.nextBigInteger(); //scan a bigInteger value System.out.println("Scaned value: " + c); //print the scanned bigInteger value } }