Print elements of a stream

Report a typo

Implement a method that prints out each element from a given stream of numbers except the first two elements.

Please, use Java Stream API to solve the problem.

Sample Input 1:

1 1 3 5 7 9

Sample Output 1:

3
5
7
9
Write a program in Java 17
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

/**
* Prints each element from a given stream except first 2 elements.
*
* @param stream the input stream of integers
*/
public static void printStream(Stream<Integer> stream) {
// write your code here
}

// Don't change the code below
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
printStream(Arrays.stream(scanner.nextLine().split("\\s+")).map(Integer::parseInt));
}
}
___

Create a free account to access the full topic