java performance : Is storing a hashMap value in a variable redundant?

后端 未结 4 863
误落风尘
误落风尘 2020-12-20 07:35

my goal is to reduce memory usage. should I store a hashMap value in a variable if I need to use that value multiple times?

public void upcCheck() {
                 


        
4条回答
  •  暖寄归人
    2020-12-20 08:11

    you should be store a hashMap value in a variable if I need to use that value multiple times. create method bound variable is create a reference to the HashMap value, then you use reference to de equeals, when you do end of the method, JVM will be callback all memory used by this method.

提交回复
热议问题