When using java stream show error while coding
Optional.ofNullable(product.getStudents())
.orElseGet(Collections.emptyList())
.stream().map(x->x.getId)
.collect(Collectors.toList());
this code shows below error ERROR
incompactible type, Required Supplier> but empty list was interfered to List : no instance of type variable of T exist so List conforms to Supplier>
But if I replace the Collections.emptyList()
WITH Collections::emptyList
It will be perfect.
What is the difference between Collections.emptyList() vs Collections::emptyList?