import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int[] array = new int[] {1, 2, 3, 4, 5};
int[] evenArray = Arrays.stream(array)
.filter(a -> a % 2 == 0)
.toArray();
System.out.println(Arrays.toString(evenArray));
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: