A Question about optimization

Im writing a program that uses classes and i was wondering which is more effecient for accessing a classes private fields. calling a public method as in

someClass.getVal();

numerous times, or copying over that value to the function running it so it only has to make that call once and it can be used numerous times?

thanks for the help

If you're going to be using the value multiple times and it's not changing, it's more efficient to copy it to a local variable and use the local variable.

Allright, Thank you :D
Topic archived. No new replies allowed.