Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating objects in java

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In above example example object is created in different way instead of using Foo f=new Foo(); f.m();
Is it A Annonymous inner class?
Please explain
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

you are correct. it is Anonymous Inner class.
(new Foo(){ }).m();

we are extending Foo class creating Object of that class. So eventually by inheritance new child of Foo can access m().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic