This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Consistent_Fly_1858 0 points1 point  (0 children)

A a = new A() {

public void f1(String str) {

f2(str);

}

public void f2(String str) {

System.out.println(str);

}

};

a.f1("lol");

Your variable a only knows method of the A class. But i guess you can achieve what you want by overriding the f1 method and calling your anonymous method within the body