Learnitweb

Java program to print the numbers from a given list of integers that are multiples of 5

You can use Java 8 Streams to filter and print numbers that are multiples of 5 using the filter() method.

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class MultiplesOfFive {
    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(10, 23, 45, 66, 75, 90, 12, 55);

        List<Integer> multiplesOfFive = numbers.stream()
                .filter(n -> n % 5 == 0) // Filter multiples of 5
                .collect(Collectors.toList());

        System.out.println(multiplesOfFive);
    }
}

Output:

[10, 45, 75, 90, 55]