This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 19654
    
  18

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
 
Similar Threads
What's up with these literal assignments?
AutoBoxing - Compilation Error
Examlab Thread question
Assinging Compile time long constant to byte fails
implecit casting