Weitere Beispiele werden automatisch zu den Stichwörtern zugeordnet - wir garantieren ihre Korrektheit nicht.
You should be aware that this is a narrowing conversion, which means you might lose information during the cast.
If no conversion exists, or only a narrowing conversion exists, the program is ill-formed.
C++ allows a range of implicit conversions between native types (including some narrowing conversions), and also allows the programmer to define implicit conversions involving user-defined types.
Each arithmetic operation on any of those types results in an int result, which must be explicitly cast back to the original type (a narrowing conversion that might lose information) to assign back to that type.
Constructor permits widening conversions to occur when matching the actual parameters to newInstance() with the underlying constructor's formal parameters, but throws an IllegalArgumentException if a narrowing conversion would occur.
A consequence of this is that although loop conditions (, and the exit condition in ) in Java and C++ both expect a boolean expression, code such as will cause a compile error in Java because there is no implicit narrowing conversion from int to boolean.