• 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: 558
  • 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().
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!