Find Smallest Number in Array using Java

Stream.min method

package app;

import java.util.Arrays;

public class Main
{
    public static void main(String[] args)
    {
        Integer[] numbers = {10, 3, 17, 50, 15};
        Integer minNumber = Arrays.stream(numbers).min(Integer::compare).get();

        System.out.println(minNumber);
    }
}

Leave a Comment

Cancel reply

Your email address will not be published.