• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Dan's Exception Handling question

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could anyone explain why the following code gives complile time error.



The explanation says that as the switch statement is unreachable , it gives compile time error . I dont understand that if the statements are unreachable why it is giving compile time error. Am i missing something here???

Thanks in advance
 
blacksmith
Posts: 979
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Maybe the following will help JLS 14.20 Unreachable Statements
Greetings,
Gian Franco
 
Gian Franco
blacksmith
Posts: 979
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again,
I was just playing with the unreachable feature
and the following code snippet is interesting:

According to the JLS the 'if(false)' is technically
speaking reachable, therefore the 'while(u<2)', which
would normally give an error since the expression is
constant (due to the final int u), compiles
perfectly fine.
Just brainstorming if you don't mind.
Greetings,

Gian Franco
[ March 19, 2004: Message edited by: Gian Franco Casula ]
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic