my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Assinging Compile time long constant to byte fails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Assinging Compile time long constant to byte fails

Harish Kommaraju
Greenhorn

Joined: Nov 10, 2009
Posts: 13
Hi,

I am aware that if you are assigning int to a byte without any implicit cast, then the int should be a compile time constant.
i.e. the below code compile fines.


But if I try the same thing with long, it fails.


Why is that compile time constant of type int can be assigned to byte without any implicit cast, but we cannot assign compile time long to byte?

Thanks,
Harish
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

Please use one thread per question. Since you've already had one reply here that is where we shall continue.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Assinging Compile time long constant to byte fails