Hi all,
I'm learning
Java 5 using
Herbert Schildt's book
"The Complete Reference - Java J2SE 5 Edition".
On page # 47 (Chapter 3: Data Types, Variables and Arrays), he mentions:
I tried the same using the following code sample shown below:
I compiled it and executed it using J2SE 1.5, without any compilation or runtime errors and the program correctly prints "100". In my observation, there isn't any problem with this piece of code.
However, the author says,
However, as I said, according to my observations, this typecasting is unnecessary
works fine by itself.
Further, consider the following code:
In both cases, whether you typecast or not, both
b and
c would print out
-56, because the result is going to overflow.
So, am I missing out something? Or did the author mean something else? Please help. Thanks.
Regards,
Jags.
[ August 10, 2005: Message edited by: Jagan Nambi ]