What is the output of the following code? public class Test { public static void main(String[] args) { java.math.BigInteger x = new java.math.BigInteger("3"); java.math.BigInteger y = new java.math.BigInteger("7"); x.add(y); System.out.println(x); } }
时间: 2024-03-31 10:37:15 浏览: 113
The output of the following code would be "3".
This code creates two BigInteger objects `x` and `y` with values 3 and 7 respectively, and then calls the `add()` method on `x` with `y` as an argument. However, it doesn't store the result of the addition back into `x`. So, `x` remains unchanged and still holds the value 3.
Therefore, when `x` is printed to the console using `System.out.println()`, it will output the value of `x`, which is 3.
阅读全文