You are not instantiating it. By writing this piece of code, you are
creating an anonymous class that implements the Runnable interface.
That's why you see the run() method inside: you are implementing it.
It's a very common pattern with interfaces in Java.
On Mon, Oct 27, 2008 at 2:04 PM, polo777 <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> My question is regarding the Runnable interface. This "Runnable" stuff
> is described as an interface in the docs nevertheless it can be
> instantiated that is surprising for me.
>
> Runnable getAllClips = new Runnable()
> {
> public void run()
> {
>
> }
> };
>
> As far as I am concerned, this syntax does not make sense for me.
>
> It is an interface but:
> - First you can instantiate it as an object
> - and then you can create a function run within it (it is a class
> now???).
>
> Can someone give me an explanation. I would be really grateful.
>
> Regards,
> Polo
> >
>
--
Romain Guy
www.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---