Why does this compile?

前端 未结 2 1502
伪装坚强ぢ
伪装坚强ぢ 2021-02-18 23:00

I was taken aback earlier today when debugging some code to find that something like the following does not throw a compile-time exception:

 public Test () { 
         


        
2条回答
  •  太阳男子
    2021-02-18 23:53

    Because conceivably getList() could be returning a subclass of HashMap which also implements List. Unlikely, yes, but possible, and therefore compilable.

提交回复
热议问题