You are passing a reference to a CI instance to the getBack method. That is the only place that reference can be used, since it is an anonymous class and you are not keeping a reference anywhere in the other class.
I am going to try some changes in Java8, like writing this
a.getBackToWork(() -> System.out.println("Used a \u03bb expression"));
instead of lines 6-13.
Oh, I am daft! I was trying the λ without the ci.checkMate() call. That is why it wouldn't work!
Start with a dir (Windows®) or ls (*nix) instruction at the command line/terminal. Count the .class files. Delete all the .class files
Make the following two changes:
Add the ci.checkMate(); line as before
Change lines 6-13 in Implement to read
a.getBackToWork(()-> System.out.println("Working with a \u03bb"));
Compile and run with Java8 only. Now count the .class files. See the difference?
Abhimanyu Jain wrote: . . .
Working with a ?
. . .
I got that, too. \u03bb is λ
So obviously the lambda does work after all.
It didn't seem to make much difference whether I added the @FunctionalInterface annotation to the interface or not.
As Rob says, the link tells you how to use code tags. Push the code button, then put the code after the ] and before the [/code.
Or highlight the entire code block and push the code button.
There is more about code tags here and here.