Import Java.util.*;import Java.math.biginteger;public class fiftysixth{public static void Main (string[] args) { BigInteger one = new BigInteger ("$"); BigInteger The new BigInteger ("the"); BigInteger three = new BigInteger ("50000"); BigInteger total = Biginteger.zero; Total.add (one); Total.add (both); Total.add (three); SYSTEM.OUT.PRINTLN (total);} }
How much output?
0
How could it be? Isn't it a plus?
Note that BigInteger is an immutable type.
Immutable types:
String,integer,bigdecimal,long,charactor,short,byte,boolean,float,double
And look at the BigInteger method:
BigInteger
add(BigInteger val)
Returns a BigInteger whose value is(this + val)
BigInteger
divide(BigInteger val)
Returns a BigInteger whose value is (this / val)
.
int
intValue()
Converts this BigInteger to an int
.
BigInteger
negate()
Returns a BigInteger whose value is(-this)
BigInteger
subtract(BigInteger val)
Returns a BigInteger whose value is (this - val)
.
It can be observed that the return value of subtraction is BigInteger, which also means that the final operation is to return the result, but does not change the original value.
I can understand that.
int i=0;
i+1+2+3+4+5+6;
So what is the value of I? Of course it's 0!!!
The big question of Java FAQ