A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Assinging Compile time long constant to byte fails
Joined: Nov 10, 2009
Nov 10, 2009 17:30:43
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.
final int b = 10; byte a = b; // compiles fine
But if I try the same thing with long, it fails.
final long b = 10; byte a = b; // Doesn't compile !!!
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?
Joined: Oct 27, 2005
Nov 11, 2009 01:47:35
use one thread per question
. Since you've already had one reply
that is where we shall continue.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
I agree. Here's the link:
subject: Assinging Compile time long constant to byte fails
What's up with these literal assignments?
Examlab Thread question
AutoBoxing - Compilation Error
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015