Posts

Showing posts with the label Java8

Java 8 Concepts with Examples

Java 8 new features  1. Lambda Expressions A lambda expression is an anonymous function. A function that doesn’t have a name and doesn’t belong to any class.   so compiler does not create .class file. Used to provide the implementation of an interface which has functional interface      //Syntax of lambda expression ( parameter_list ) -> { function_body }      Example: Creating Thread with Lambda  package com.vasanth.java8; public class ThreadWithLambda { public static void main (String args[]){ //Traditional approach Runnable r1= new Runnable() { @Override public void run() { System. out .println( "Thread 1 started" ); } }; Thread t1= new Thread(r1); t1.start();                                        //With Lambda Runnabl...