Skip to content

Instantly share code, notes, and snippets.

@jackblack369
Created February 27, 2019 16:15
Show Gist options
  • Save jackblack369/978425d9bcb68bacfebba5da8f12c7c4 to your computer and use it in GitHub Desktop.
Save jackblack369/978425d9bcb68bacfebba5da8f12c7c4 to your computer and use it in GitHub Desktop.
[learn-Functional Interfaces] #java

Java 8 Functional Interfaces

Being object oriented is not bad, but it brings a lot of verbosity to the program. Java 8 Functional Interfaces and Lambda Expressions help us in writing smaller and cleaner code by removing a lot of boiler-plate code.

  • An interface with exactly one abstract method is called Functional Interface. @FunctionalInterface annotation is added so that we can mark an interface as functional interface.
  • Some of the useful java 8 functional interfaces are Consumer, Supplier, Function and Predicate.

Lambda Expression

  • Objects are the base of java programming language and we can never have a function without an Object, that’s why Java language provide support for using lambda expressions only with functional interfaces.
  • Lambda Expressions syntax is (argument) -> (body).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment