Short Version:
I understand that it's a bad practice to import * and it's best to import what exactly we need explicitly. However, I'm curious why importing util.* does not include util.stream.*.
Long Version:
If I import java.util.stream.*;
this piece of code works successfully:
int[] a = {3, 4, 1};
ArrayList<Integer> list = Arrays.stream(a)
.boxed()
.collect(Collectors.toCollection(ArrayList::new));
However, if I remove the stream from the import:
import java.util.*;
It fails:
Main.java:20: error: cannot find symbol
.collect(Collectors.toCollection(ArrayList::new));
^
symbol: variable Collectors
location: class Ideone
1 error
I have tried with Java 8 (1.8.0_201):
https://www.onlinegdb.com/online_java_compiler
Java 11 (11.0.11+9-Ubuntu-0ubuntu2.20.04):
https://www.programiz.com/java-programming/online-compiler/
and Java 12 (12.0.1+12):