In this code snippet example you will learn how implement the Interface with Syntax java Lambdas, Old Way and New Ways in Java8 Lambdas.
Let’s see the code snippet below as an example:
package com.putracode._01_helloworld; public class HelloWorld_Lambdas { public static void main(String[] args) { // Old ways, Implementatios The Interface IHelloWorld IHelloWorld oldWays=new IHelloWorld() { @Override public void process() { System.out.println("HelloWorld Old Way"); } }; // New Ways.. Lambdas Expression IHelloWorld newWays=()->{System.out.println("Hello World New Way, Lambda");}; // call the method oldWays.process(); newWays.process(); } } interface IHelloWorld{ void process(); }
If you’d like to view the source code , it’s available on Github .
Happy Coding.. ^_^