I think this question is already out there somewhere, but I could not find it.
I do not understand why you need to have a functional interface for working with lambdas. Consider the following example:
public class Test { public static void main(String...args) { TestInterface i = () -> System.out.println("Hans");
This works without problems, but if you uncomment the commented lines, it is not. What for? In my opinion, the compiler should be able to distinguish both methods, since they have different input parameters. Why do I need a functional interface and explode my code?
EDIT: Related duplicates did not answer my question because I am asking about different method parameters. But I got some really useful answers here, thanks to everyone who helped! :)
EDIT2: Sorry, I'm obviously not a native speaker, but to clarify:
public interface TestInterface { public void hans();
All I ask is about the arguments. The name of the method does not matter, but each method takes a unique order of various arguments, and because of this, Oracle can implement this function, and just make the only method possible for the "Lambda interface".
java lambda java-8 functional-interface
codepleb Oct 08 '15 at 8:34 2015-10-08 08:34
source share