It's not a secret anymore!
The moose likes Beginning Java and the fly likes Anonymous clases Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Anonymous clases" Watch "Anonymous clases" New topic

Anonymous clases

Sigfred Zamo
Ranch Hand

Joined: Mar 04, 2002
Posts: 44
I�m studying Sun�s Java tutorial.
At, second question.
I simplified the question, I could arrive to this:

Could somebody explain to me this code snippet?
What is the meaning of t instance?
[ April 06, 2002: Message edited by: Cindy Glass ]

Sigfred Zamo<br />Software Development<p><a href="" target="_blank" rel="nofollow">My page</a>
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
The Timer is smart enough to know that something is supposed to be done -- it just doesn't have a clue what. A TimerTask subclass, here an annoymous class, handles the actions. If you know about threads, this is similar to

The code Sun wrote could also be written like this:

[ April 06, 2002: Message edited by: Cindy Glass ]
I agree. Here's the link:
subject: Anonymous clases
It's not a secret anymore!