Quantcast
Channel: How to cast generics in a loop? - Stack Overflow
Browsing all 3 articles
Browse latest View live

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 Article



Answer 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 Article

How 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
Browsing all 3 articles
Browse latest View live




Latest Images