File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -349,10 +349,32 @@ interfaces implemented by the superclass.
349349
350350### Argument Defined Anonymous Inner Class
351351
352+ Consider the below code:
352353
354+ {% highlight java linenos %}
355+ class MyWonderfulClass {
356+ void go() {
357+ Bar b = new Bar();
358+ b.doStuff(new Foo() {
359+ public void foof() {
360+ System.out.println("foofy");
361+ } // end foof method
362+ }); // end inner class def, arg, and b.doStuff stmt.
363+ } // end go()
364+ }
353365
366+ interface Foo {
367+ void foof();
368+ }
354369
370+ class Bar {
371+ void doStuff(Foo f) {
372+ }
373+ }
374+ {% endhighlight %}
355375
376+ The ` doStuff(Foo f) ` in ` Bar ` class takes an object of a class that implements ` Foo ` interface. So, we just passed an
377+ anonymous class which is an implementation of the ` Foo ` interface as an argument to the ` doStuff() ` method (in line 4).
378+ This we call it as __ Argument Defined Anonymous Class__ .
356379
357-
358380
You can’t perform that action at this time.
0 commit comments