Calling a getter multiple times or calling once and assigning to a variable?

后端 未结 13 1684
无人共我
无人共我 2021-02-05 15:26

say suppose I have class as :

public class Age {

    private int age;

    public int getAge() {
       return this.age;
    }

}

In my Main c

13条回答
  •  生来不讨喜
    2021-02-05 15:39

    You won't see much change in performance unless if you are doing many operations inside the getAge() method.

提交回复
热议问题