Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes creating objects in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "creating objects in java" Watch "creating objects in java" New topic

creating objects in java

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 224

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

Joined: Feb 15, 2007
Posts: 557

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().

Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
I agree. Here's the link:
subject: creating objects in java
It's not a secret anymore!