IntelliJ Java IDE
The moose likes Java in General and the fly likes Anonymous inner class and Exception Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Anonymous inner class and Exception Handling" Watch "Anonymous inner class and Exception Handling" New topic
Author

Anonymous inner class and Exception Handling

Marco Pacini
Greenhorn

Joined: Mar 16, 2010
Posts: 5
Hi all.

I'm studying inner class and i don't understand why it isn't possible throw an anonymous inner class like following exemple:


Regards
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18365

Does AnonymousInnerClass extend Throwable, Exception, RuntimeException or any other exception class? The following is perfectly legal:


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Marco Pacini
Greenhorn

Joined: Mar 16, 2010
Posts: 5
If i define the inner class when throw it, can i explain that it extend Throwable, Exception, RuntimeException or any other exception class?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

Marco Pacini wrote:If i define the inner class when throw it, can i explain that it extend Throwable, Exception, RuntimeException or any other exception class?


Of course.

and this can be an inner class if you like.
 
 
subject: Anonymous inner class and Exception Handling
 
Threads others viewed
What is this technique called?
Is there a way to instantiate anonymous inner class?
Q: Anonymous inner class extending outer class
Packaging Classes Question
Passing an object to a method.
jQuery in Action, 2nd edition