The code only looks the same. The method Arrays.stream that is being called is actually different in both cases:
On a Stream<String>, you can call map and return a Stream<R> based on the return type of the mapper. But on a LongStream, map will always return a LongStream, that is the primitive specialization. What happens is that Long::valueOf will turn your long element into a Long object and then it will be automatically unboxed into a long; effectively, the call is doing nothing except a box / unbox.
Then the problem appears on the collect call.
LongStream.collect expects 3 arguments
Stream.collect has a 3 argument method but also a 1 argument method, which is the one you call with .collect(Collectors.toSet());.
So you can't call .collect(Collectors.toSet()); on a LongStream. This won't compile: it expects 3 arguments.
What you can do is call mapToObj instead of map on the LongStream: this method declares to return a Stream<R> (instead of a LongStream) from the return type of the mapper. In this case, the mapper is Long::valueOf that returns a Long object so it will return a Stream<Long>.
To recap:
long la[] = new long[] {1,2,3};
Arrays.stream(la).map(Long::valueOf).collect(Collectors.toSet());
//^--LongStream----^^---LongStream----^^ error
String la[] = new String[] {"1","2","3"};
Arrays.stream(la).map(Long::valueOf).collect(Collectors.toSet());
//^-Stream<String>-^^--Stream<Long>--^^---- successful call -----^
long la[] = new long[] {1,2,3};
Arrays.stream(la).mapToObj(Long::valueOf).collect(Collectors.toSet());
//^--LongStream----^^-----Stream<Long>-----^^---- successful call -----^