This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes i'm desperate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "i Watch "i New topic
Author

i'm desperate

khella smith
Ranch Hand

Joined: May 06, 2002
Posts: 39
hi again,
wat does it mean when u have
final int i = 10;
byte k = i;
u compile this and u get no error
but when u take out the final modifier u get an error. does it have something to do with the final being regarded as a constant or what
some explanations would be highly regarded
thanxs
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Yes, when the variable is final it is treated as a constant that the jvm knows will fit into a byte. As soon as you remove the final attribute, then the variable is at risk of being something that will NOT fit into a byte, and you get an error.


"JavaRanch, where the deer and the Certified play" - David O'Meara
khella smith
Ranch Hand

Joined: May 06, 2002
Posts: 39
thanxs cidy
now i can answer a question with more confidence
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i'm desperate
 
Similar Threads
Casting
from JLS
can final variables instantiated after they declare
Static Imports doubt!
q on interfaces