DUET PG Score Card 2021
NHAI Recruitment 2021
Bihar Board 12th Dummy Admit Card 2022
RBI Assistant Notification 2021
Jee Advanced 2021 Result
NIACL Assistant Recruitment 2021
SBI PO Online Form 2021

Complete the code in LambdaExpression.java file to print all odd elements in the array list using concept of lambda expression

// Complete below given code as per the problem statement
import java.util.ArrayList;
class LambdaExpression{
	public static void main(String args[]){
		ArrayList<Integer> ArrList = new ArrayList<Integer>();
		ArrList.add(120);
		ArrList.add(303);
		ArrList.add(308);
		ArrList.add(555);
		//Complete the code for displaying elements using lambda expression
		ArrList.forEach(n -> System.out.println(n));
		
		System.out.println("All odd elements displayed");
		  ArrList.forEach(n-> { if (n%2 != 0) System.out.println(n); });  
		  
		  // Complete the Lambda
		
	}
}

Leave a Comment