Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
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:
Beginning Java
return statement ends method invocation
leo donahue
Ranch Hand
Posts: 327
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If you have a void method called doSomething() that looks like this:
public static void doSomething(){ return; System.out.println("doSomething"); }
Is the fact that the println statement being "unreachable" a product of my
IDE
, or the JLS?
JLS says statements after a return statement are not executed.
init: deps-jar: Compiling 1 source file to C:\Webapps\MyName\build\classes C:\Webapps\MyName\src\myname\Main.java:43: unreachable statement System.out.println("doSomething"); 1 error BUILD FAILED (total time: 0 seconds)
Thanks, leo
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It's the JLS. Later on the same page:
Unreachable statements.
[Jess in Action]
[AskingGoodQuestions]
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Unreachable, return in finally or catch
unreachable statement
Unreachable code ?
Unreachable code?
no return
More...