Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Cattle Drive
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Cattle Drive
Variable Scope and Life time
Tharindu Priyath
Greenhorn
Posts: 6
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class Example{ public static void main(String args[]){ final int x=101; int y; if(x>100){ y=-1; } System.out.println(y); } }
This program is correct.
class Example94{ public static void main(String args[]){ final int x; x=101; int y; if(x>100){ y=-1; } System.out.println(y); } }
But this program is compile error.Why
Campbell Ritchie
Marshal
Posts: 79177
377
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Welcome to the Ranch
Please look at a few threads in
our “beginning Java” forum
:
1
2
3
4
.
Are there several people all in the same class who are struggling with this question? All those threads appear to be about the same question as you are asking here. They will also probably answer your question.
Campbell Ritchie
Marshal
Posts: 79177
377
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have added
code tags
to your post, and you can see how much better it looks
Please always use those tags.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Final variables
Variable scope & life time
Why there is a compiler error?
final variables
final variables
More...