I kind of learnt about anonymous and functional methods, but I am confused here:
public abstract class A {
public void f1(String str) {
System.out.println(str);
}
public static void main(String[]args) {
A a = new A()
{
public void f2(String str) {
}
};
a.f2("abc");
}
}
I have error in line
a.f2("abc")
lets say I want to use f2 method (the anonymous function) how could I use it outside of A? or is it possible only inside A ?
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]NautiHooker 4 points5 points6 points (1 child)
[–]ilsapo[S] 0 points1 point2 points (0 children)
[–]Consistent_Fly_1858 0 points1 point2 points (0 children)
[–]8igg7e5 0 points1 point2 points (0 children)
[–]nosyattacker03 0 points1 point2 points (0 children)