Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 Shaquil   Members   -  Reputation: 818

Like
0Likes
Like

Posted 02 June 2013 - 09:13 AM

[Removed]


Edited by Shaquil, 07 August 2015 - 06:47 AM.


#2 rip-off   Moderators   -  Reputation: 10547

Like
2Likes
Like

Posted 02 June 2013 - 10:36 AM

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.



#3 Shaquil   Members   -  Reputation: 818

Like
0Likes
Like

Posted 02 June 2013 - 05:57 PM

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.



#4 dmatter   Crossbones+   -  Reputation: 4066

Like
0Likes
Like

Posted 03 June 2013 - 02:53 AM

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.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.




PARTNERS