Is there no autoboxing for BigInteger?
Juned and hexafraction have already pointed out that autoboxing works between primitives and their corresponding Wrappers.
As to why BigInteger
doesn't have a corresponding primitive would tantamount to answering your second question:
If not, what is the rule for the types supporting autoboxing and why isn't BigInteger included?
Primitives are variables a CPU supports to operate directly, with BigInteger
this isn't possible. This is a class that supports operation with massive numbers, and such operations require considerably more management.
Every modern computer has a machine-language instruction for integer addition. Therefore it can also have very simple byte code in the JVM. A complex type like BigInteger
cannot be handled that way, and it cannot be translated into simple byte code. Therefore, it cannot be a primitive.
Since it's a class and Java doesn't support operator overloading, you are required to use its methods and constructors instead of the simple arithmetic operators that you'd be able to use with primitives.