0
I'll provide in description
I can't understand the steps used in main method please explain!! Or tell me the concept used interface test{ int a(int b,int c); static String show(){ return "hello"; } } public class Main{ public static void main (String[] args) { test r=(p,q)->p+q; System.out.println(r.a(1,2)+test.show()); } }
2 ответов
+ 3
interface which has only one method to implement, is called functional interface and
can be implemented by lambda expression :
test r = (p, q) -> p + q;
same as
class TestImpl implements test {
int a (int a, int b) {
return a + b;
}
}
+ 2
All of this is Java 8 features, you might want to read a little bit about it in order to understand how it is implemented.
Concepts you need to particularly look into include-
1) Functional interface
2) Static methods in interface
3) Lambda expressions