This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need clarification in basics  RSS feed

 
dinesh Venkatesan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
regards,
dinesh.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!