我试图弄清楚stream.of()和之间的差异在哪里stream(),我遇到了这个。谁能向我解释为什么第一个不起作用?
//Given: List<Integer> transactions
transactions.add(1);
transactions.add(2);
//This won't compile,
Stream.of(transactions).filter(x->x<3).collect(Collectors.toList());
// while this one does fine:
transactions.stream().filter(x->x<3).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)