• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception Handling  RSS feed

 
Arul Prasad
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all

i was strange of behaviour of the Exception handling ... let me explain with example

DemoException.java ver 1.0

the above code is working perfect with out any compile error
but when i change my code like
DemoException.java ver2.0

This code throws the compile error stating

DemoException.java:30: missing return statement

what could me the reason ...

but it working when i change my code as
DemoException.java ver3.0


i want to why my SeconVersion is not working .....
 
Paul Santa Maria
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because your "throwInternalException" is just an ordinary function call.

As far as the compiler is concerned, it will return after it's done (you know it won't, I know it won't - but the compiler thinks it will!). And there's no "return" afterward in your version 2. There *is* a return in version 3. and you're not making a function call in version 1.

'Hope that helps .. PSM
 
Babu Rajendra Prasath Haridass
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi arul,
as for as compiler is concern..it is just a method and the compiler is expecting the "return" statement after a method call.even you throw the exception in the "throwInternalException" method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!