Why define object for getEntry in HashMap

后端 未结 4 940
盖世英雄少女心
盖世英雄少女心 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:49

    This is an extreme optimization measure that is probably not necessary for general purpose programming practice. Here is a discussion that could answer your question. Below statement is copied from that post:

    It's a coding style made popular by Doug Lea. It's an extreme optimization that probably isn't necessary; you can expect the JIT to make the same optimizations. (you can try to check the machine code yourself!) Nevertheless, copying to locals produces the smallest bytecode, and for low-level code it's nice to write code that's a little closer to the machine.

提交回复
热议问题