How to find Min value of Integer using Java8 feature ?

 Interview Question

How to find Min value of Integer using Java8 feature ?

Solution :

package p2;

import java.util.ArrayList;

import java.util.List;


public class MinOfInteger {


public static void main(String[] args) {

List<Integer> list=new ArrayList<>();

list.add(1);

list.add(10);

list.add(21);

list.add(13);

list.add(15);

Integer min=list.stream().mapToInt(i->i).min().getAsInt();

System.out.println(min);


}


}

****************************************************************************
O/P : 1

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?