File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 17259

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: 12869

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
 
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture