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

How to create React project using command prompt?

How to achieve abstraction?

Interview Question? How to find square of each element in this Array {2,4,5,6,8} using map ?