File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Implict Cast Narrowing Doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Implict Cast Narrowing Doubts" Watch "Implict Cast Narrowing Doubts" New topic

Implict Cast Narrowing Doubts

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
From web page

I know at line 3,it will have compiler error.
Why at line 6 is not given the compiler error...
float is 32 bit and long is 64 bit
so it's narrowing anf for for narrowing the implicit cat will work if the assigned value is compiler time constant..
But above the float l is assigned a run time value..then why it is not given error.. pls clarify

Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Ranch Hand

Joined: Nov 10, 2006
Posts: 127

Compilation error "loss of precision" on the last 2 lines, not any above! ???

Hard work rewards
Tommaso Nuccio
Ranch Hand

Joined: Dec 11, 2006
Posts: 66

the last two lines are assignments, while the others before are simply modifications of the value itself.

Ciao,<br /> Tommaso<br /> <br />~*~*~*~<br />There are 10 types of people, those who understand binary and those who don't.
I agree. Here's the link:
subject: Implict Cast Narrowing Doubts
It's not a secret anymore!