File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Need clarification in basics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need clarification in basics " Watch "Need clarification in basics " New topic

Need clarification in basics

dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Hi Friends,

This should be a very basic thing but i am left with no clues. Sorry if i am wrong.
I have seen a code snippet in an example

Could anybody explain the above mentioned snippet. How could a method be defined inside another method.

Thanks in advance.
marc weber

Joined: Aug 31, 2004
Posts: 11343

This is the syntax for an anonymous class (although it's missing a semicolon at the end).

The block of code following the call "new Thread()" is the body of an anonymous class that extends Thread. In this example, the anonymous class is used to override Thread's run method.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Need clarification in basics
jQuery in Action, 3rd edition