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

后端 未结 13 1682
无人共我
无人共我 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:40

    There may be some performance overhead of calling the getAge() method many many times, but I suggest you consider The Sad Tragedy of Micro-Optimization Theater.

提交回复
热议问题