Jump to content
  • Advertisement
Sign in to follow this  
Liuqahs15

[JAVA] Upcasted Anonymous Classes: Can You Access Unique Fields/Methods?

This topic is 1841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

Short of reflection, no. Also, don't use reflection =].

 

Anonymous inner classes are usually used to override the behaviour of one or more methods, most commonly single method interfaces such as Runnable, Callable and event handlers.

Share this post


Link to post
Share on other sites

Short of reflection, no. Also, don't use reflection =].

 

Anonymous inner classes are usually used to override the behaviour of one or more methods, most commonly single method interfaces such as Runnable, Callable and event handlers.

 

Thanks. I've never heard of reflection, so I'll have to look it up.

Share this post


Link to post
Share on other sites

are anonymous inner classes mostly for overloading a few methods without creating an entirely new class to do so?

Yes exactly, with "a few methods" usually being 1 or 2.
Typically they will just be implementing an interface too so all the behaviour is actually coming out of the anonymous class.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!