I would like convert a List without generics to List<MyConcreteType>.
I also need to filter out only my concrete types.
My current stream logic is like:
List list = new ArrayList();
Object collect1 = list.stream().filter((o -> o instanceof MyConcreteType)).collect(Collectors.toList());
But as a result I'm getting an Object instead of a List. Is there a way to convert this Stream to a List<MyConcreteType>?
List<MyConcreteType> typedList = (List<MyConcreteType>) list.list.stream().filter(MyConcreteType.class::isInstance).map(MyConcreteType.class::cast).collect(Collectors.toList())then