Answer by gabuzo for How to cast generics in a loop?
I think the best way would be:public static void someMethod(List < ? extends BaseDto > list) { for (BaseDto dto : list) { ChildDto taDTO = (ChildDto)dto; // Whatever }}It also allows you to use...
View ArticleAnswer by Joachim Sauer for How to cast generics in a loop?
ChildDto extends BaseDto and here I'm sure its the list full of ChildDto.Then why doesn't the argument type of that method represent that knowledge?It should be List<ChildDto> or even List<?...
View ArticleHow to cast generics in a loop?
public static void someMethod(List < ? extends BaseDto > list) { for (ChildDto dto : list) { }}ChildDto extends BaseDto and here I'm sure its the list full of ChildDto.I do know I can do...
View Article
More Pages to Explore .....