• Functional interfaces introduces in java 8 .
  • Functional interfaces will have single abstract method in it.
  • Check here for full details on Java 8 functional interface with example.
  • Functional interfaces will be implemented by java 8 Lamda expressions.
  • Lets see an example program on how can we use functional interfaces or how can we implement functional interfaces using Lamda expression in java 8.
  • Create one functional interface with one abstract method in it.
  • Create a class and implement this abstract method using Lamda Expressions.



#1: Java example program to create functional interface.

functional interface example in java 8 using lamda expressions


#2: Java example program to implement functional interface using Lamda expressions in java 8.

  1. package com.instanceofjava.java8;
  2. /**
  3.  * @author www.Instanceofjava.com
  4.  * @category interview programming questions
  5.  * 
  6.  * Description: java 8 Lamda expressions
  7.  *
  8.  */
  9. public class LamdaExpressions {

  10. public static void main(String[] args) {
  11. FunctionalInterfaceExample obj = ()->{
  12. System.out.println("hello world");
  13. };

  14. obj.show();
  15. }

  16. }

Output:

  1. hello world

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu