How to Find MAX value Of Integer by using Java 8 feature?

 Interview Question

How to Find MAX value Of Integer by using Java 8 feature?

Solution :

package p2;

import java.util.Arrays;
import java.util.List;

public class MaxOfInteger {

public static void main(String[] args) {
List<Integer> list=Arrays.asList(10,15,25,50);
Integer max=list.stream().mapToInt(i->i).max().getAsInt();
System.out.println(max);

}

}

********************************************************************

O/P : 50

Comments

Popular posts from this blog

What are POJO classes in spring? What is the use of POJO Class, and How to create POJO classes.

How to create React project using command prompt?