Map.get() optimization in ?: ternary operator

后端 未结 3 874
礼貌的吻别
礼貌的吻别 2021-01-22 10:33

Consider the following code:

java.util.Map map = new java.util.HashMap();
...
String key = \"A\";
String value = map.         


        
3条回答
  •  离开以前
    2021-01-22 11:07

    The IF one is preferable.

    Its more readable & self explained.

    Additionally: execution time is not a big deal, at least here.

提交回复
热议问题