-1

How, technically speaking, collect(toList()) can return Object?

Stream y = Stream.of("X");
Object l = y.collect(Collectors.toList());

I would not be surprised by List, but Object that surprising.

Vlad Sh
  • 25
  • 1

1 Answers1

-1

It can return List<String> also, but it is normal to get an Object because List is extended from Object.

final List<String> x = Stream.of("X").collect(Collectors.toList());
Ekrem Demirhan
  • 204
  • 3
  • 11