Why define object for getEntry in HashMap

后端 未结 4 941
盖世英雄少女心
盖世英雄少女心 2020-12-21 20:56

I am new to generics and I am not sure if the answer to my question is opinion based or has a genuine reason. In the following code what was need to case a key

4条回答
  •  梦毁少年i
    2020-12-21 21:40

    You've missed the last part of where key is checked for equality with k, so removing assignment (k = e.key) will break the last check -

    if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k))))

提交回复
热议问题