Lambda Expression Basics and Syntax - Java8
In simple term, a Lambda Expression is implementation of a Functional Interface. Lambda Expression is a way to provide implementation of a functional interface without creating a Class or Anonymous Inner Class. Note that Lambda can implement only a functional interface. Read more about Functional Interface Here is a functional interface named Processor which has single abstract method called process And let say there is processValue method, which takes a value and a Processor object as input, apply processor on the value and return the result. private int processValue(int value, Processor processor) { return processor.process(value); } Call processValue method using Anonymous Inner Inner Class as implementation of Processor interface. processValue(10, new Processor() { @Override public int process(int input) { return input * 2; } }); It’s easily noticeable the unnecessary verbose code that we had to write for anonymous inner class. Only important line which is d...