### Example 1: Java 8 program to print odd numbers from a List

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

/*Java 8 Program to find Odd Numbers from a List*/
public class DriverClass {
public static void main(String[] args) {
List<Integer> numbers = Arrays.
asList(1, 4, 8, 40, 11, 22, 33, 99);
List<Integer> oddNumbers = numbers.stream().
filter(o -> o % 2 != 0).
collect(Collectors.toList());
System.out.println(oddNumbers);
}
}

### Example 3: Java 8 program to print even numbers from an array

import java.util.Arrays;

/*Java 8 Program to find Even Numbers from an Array*/
public class DriverClass {
public static void main(String[] args) {
int[] numbers = {2, 5, 7, 8, 99, 1, 22, 4, 3, 77, 66};
Arrays.stream(numbers).filter(o -> o % 2 == 0).
forEach(System.out::println);
}
}

### Example 4: Java 8 program to print odd numbers from an array

import java.util.Arrays;

/*Java 8 Program to find Odd Numbers from an Array*/
public class DriverClass {
public static void main(String[] args) {
int[] numbers = {2, 5, 7, 8, 99, 1, 22, 4, 3, 77, 66};
Arrays.stream(numbers).filter(o -> o % 2 != 0).
forEach(System.out::println);
}
}

### Example 5: Java 8 program to print odd numbers from a Set

import java.util.Set;
import java.util.stream.Collectors;

/*Java 8 Program to find Odd Numbers from a set*/
public class DriverClass {
public static void main(String[] args) {
Set<Integer> numbers = Set.of(1, 4, 8, 40, 11, 22, 33, 99);
Set<Integer> oddNumbers = numbers.stream().
filter(o -> o % 2 != 0).
collect(Collectors.toSet());
System.out.println(oddNumbers);
}
}

### Example 6: Java 8 program to print even numbers from a Set

import java.util.Set;
import java.util.stream.Collectors;

/*Java 8 Program to find even numbers from a set*/
public class DriverClass {
public static void main(String[] args) {
Set<Integer> numbers =Set.of(1, 4, 8, 40, 11, 22, 33, 99);
Set<Integer> evenNumbers = numbers.stream().
filter(o -> o % 2 == 0).
collect(Collectors.toSet());
System.out.println(evenNumbers);
}
}