What to prefer in the following case?
Posted
by GK
on Stack Overflow
See other posts from Stack Overflow
or by GK
Published on 2010-05-12T17:16:25Z
Indexed on
2010/05/12
17:24 UTC
Read the original article
Hit count: 151
java
|premature-optimization
say suppose I have class as :
public class Age {
private int age;
public int getAge() {
return this.age;
}
}
In my Main class I am calling the getAge() method many times.
So I wanted to know is it advisable to call so many times or call once and assign it to some variable and use that variable.
Which is best and why?
© Stack Overflow or respective owner