I am collecting String in List using Java 8. But, this is giving me compile error that
incompatible types: inference variable T has incompatible bounds equality constraints: String lower bounds: Object
final List<ProjectLevel> levels = projectLevelFacade
.findUUIDByNameorNumber(freeText, businessAccountId);
final List<String> uuids = levels
.stream()
.map((level) -> level.getProjectLevelsUUIDs()) // this return List<String>
.flatMap(Collection::stream)
.collect(Collectors.toList());
can any one have idea how to achieve this using Java 8?
Is there any type of casting or something for this?
I have also taken reference from here.
ProjectLevel
is a generic class - when you writeList<ProjectLevel>
you are using a raw type and the type inference system does not work any longer.Try:
and it should compile as expected.