Lambda expression example in java 8

Functional Interface:  An interface with only one abstract method
package org.lamda;

public interface Fun {
public void makeFun(String f);

Lambda Expression: (->)  Lambda expressions are anonymous functions, we can pass as a parameter to a function instead of object.

package org.lamda;
public class Myclass {
public static void main(String[] args) {
             //LAMBDA expression
  Fun i = (String k) ->{
System.out.println(“hello world ” + k);
System.out.println(“Maddy is a funny guy!!”);
hello world koti
Maddy is a funny guy!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks