Forums Register Login

i'm desperate

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
thanxs cidy
now i can answer a question with more confidence
Nothing? Or something? Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 652 times.
Similar Threads
Casting
q on interfaces
from JLS
can final variables instantiated after they declare
Static Imports doubt!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:59:21.