Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i'm desperate

 
khella smith
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
khella smith
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanxs cidy
now i can answer a question with more confidence
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic