You need to return a LongStream consisting of all numbers from -n to n inclusively, but skipping the 0 value.
Streams of primitives
A stream without zero
Report a typo
Sample Input 1:
3Sample Output 1:
-3 -2 -1 1 2 3Write 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);
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.