The logical equivalent of what is happening is:
Extending the class TimerTask
, e. g. MyTimer extends TimerTask
Creating an instance of the new class MyTimer mt = new MyTimer()
The actual function call timer.schedule(mt, 0, 5*1000);
The concept is called annonymous inner class. That's what's happening in step one. Step two and three can also be combined. Instances can directly be created where they're needed. That is called annonymous object.
For more insight you should read up on these concepts. They're not hard to grasp. They're often used if you need a standard instance of an interface (for example ActionListener
in GUI programming).
For completness' sake, there is also an idiom called double brace initialization. But it's not a good practice in general.