0 votes
389 views
in Java by
How will you find the lowest number in a list by using Java 8?

1 Answer

0 votes
by (5k points)
See the following running example code to get lowest number in a list by using java 8:-
package com.java8.array;

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

public class LowestNumberInList {

    public static void main(String[] args) {

        List<Integer> integers = Arrays.asList(83, 4, 56, 7, 89, 10);
     
        Integer max = integers.stream()
                              .mapToInt(v -> v)
                              .min().
                              orElseThrow(NoSuchElementException::new);
        System.out.println("Minimum Interger value: "+max);
    }

}
Output:-
Minimum Interger value: 4

Share:- Whatsapp Facebook Facebook


Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

...