You must use mapToIntwith Long::intValueto extract the value int:
List<Integer> student = studentLong.stream()
.mapToInt(Long::intValue)
.boxed()
.collect(Collectors.toList())
The reason you get method "valueOf" can not be resolved.it is because there is no signature Integer::valueOfthat takes Longas an argument.
EDIT
Per Holger's comment below, we can also do:
List<Integer> student = studentLong.stream()
.map(Long::intValue)
.collect(Collectors.toList())
source
share