Java Reference
In-Depth Information
Any Java type (including the primitive types such as integers, and boolean true
or false ) can be converted into a string. When the target of a math function (+
in this case) is a string, Java will automatically call the toString() method.
These features are why the previous statements cause this output:
...
compareTo = 0
equals = true
Java automatically converted the results of these methods (an integer result in
one case, and a boolean result in the other) into strings suitable for the
println() method.
Java's numeric wrapper classes can contain numeric data types, such as double and
integer . These wrapper classes have specific uses (generally when an object data
type is required) but are not well suited for use as a general-purpose data store.
Java's BigNumber classes ( BigInteger and BigDecimal ) are the appropriate choice
when large, fixed-precision numbers are required. These classes provide the de-
veloper with unlimited precision capabilities and explicit control over scale
and rounding. However, since they do not perform as well as the primitive data
types and cannot use the standard Java math operators, developers must de-
termine on a case-by-case basis if these data types should be used or if the
primitive data type should be used.
Search WWH ::




Custom Search