For some reason, I don’t understand, in the second case, the output input error is not executed. But you can specify the typet
List<Trade>trades = otrades.stream()//*******
.sorted(Comparator.comparing( (Trade t) -> t.getMeta().getTradeDate())
.thenComparing(t -> t.getName()))
.collect(Collectors.toList()));
In your example, the compiler found that t- this is something else that a Trade(possibly Object). Therefore, the method getMeta()cannot be found.
source
share