java超大数字的比较

import java.math.BigInteger;
import java.util.Scanner;

public class Code1014{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		BigInteger a = in.nextBigInteger();
		BigInteger b = in.nextBigInteger();
		
		if (a.compareTo(b) < 0) {
			System.out.println("a is less than b");
		} else if (a.compareTo(b) > 0) {
			System.out.println("a is greater than b");
		} else System.out.println("a is equal to b");
	}
}

你可能感兴趣的:(java,#,java基础题)