| Every expression written in the Java programming language has a type that can
be deduced from the structure of the expression and the types of the
literals, variables, and methods mentioned in the expression. It is possible,
however, to write an expression in a context where the type of the expression
is not appropriate. In some cases, this leads to an error at compile time. In
other cases, the context may be able to accept a type that is related to the
type of the expression; as a convenience, rather than requiring the
programmer to indicate a type conversion explicitly, the language performs an
implicit conversion from the type of the expression to a type acceptable for
its surrounding context.
Supported conversion types:
- Widening conversion
- String conversion
Widening conversion
Widening conversions do not lose information about the overall magnitude of a
numeric value.
String conversion
If only one operand expression is of type String, then string conversion is
performed on the other operand to produce a string at run time. The result is
a reference to a String object (newly created, unless the expression is a
compile-time constant expression (§15.28))that is the concatenation of the
two operand strings. The characters of the left-hand operand precede the
characters of the right-hand operand in the newly created string. If an
operand of type String is null, then the string "null" is used instead of
that operand.
version: $Revision: 1.2 $ |