Thursday, 8 June 2017

Java Tutorial: Lambda expression in java | Java Lambda expressions[Lambda expression-foreach loop] ~ foundjava


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=Cmrrk7D_-bM&list=UUhwKlOVR041tngjerWxVccw



LambdaDemo.java

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * Java Lambda Expression Example: For-each Loop
 *
 */
public class LambdaDemo
{

    public static void main(String[] args)
    {
        List<String> nameList = new ArrayList<String>();
        nameList.add("Ram");
        nameList.add("Peter");
        nameList.add("John");

        nameList.forEach((name) -> System.out.println(name));
    }

}
Output
Ram
Peter
John
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_for_each_App.zip?attredirects=0&d=1

No comments:

Post a Comment