Cast element in Java For Each statement

前端 未结 5 2030
囚心锁ツ
囚心锁ツ 2021-02-19 00:30

Is it possible (or even advisable) to cast the element retrieved from a for each statement in the statement itself? I do know that each element in list will be of type <

5条回答
  •  我在风中等你
    2021-02-19 01:03

    Do you really know that each entry is going to be a subtype ? The DAO simply has to fulfill the List contract, and if you're assuming a subclass, then I think something is wrong somewhere. I'd perhaps concentrate more on getting the interface to the DAO correct, and have it contractually return what you want.

提交回复
热议问题