How should lists be cast to their conrecte implementations?

前端 未结 9 748
小蘑菇
小蘑菇 2021-01-15 00:49

Let\'s suppose I\'m using a library for which I don\'t know the source code. It has a method that returns a List, like so:

public List getObjs         


        
9条回答
  •  独厮守ぢ
    2021-01-15 01:24

    You're correct. That is not a good idea. You need to use the interface form that it's returning.

提交回复
热议问题