A stream without zero

Report a typo

You need to return a LongStream consisting of all numbers from -n to n inclusively, but skipping the 0 value.

Sample Input 1:

3

Sample Output 1:

-3 -2 -1 1 2 3
Write a program in Java 17
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

class StreamOfPrimitives {

public static LongStream getLongStream(int n) {
// write your code here
}

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int n = scanner.nextInt();

String result = getLongStream(n).mapToObj(e -> e)
.map(Object::toString)
.collect(Collectors.joining(" "));

System.out.println(result);
}
}
___

Create a free account to access the full topic