This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Android and the fly likes performance overhead for setters and getters in Android? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "performance overhead for setters and getters in Android?" Watch "performance overhead for setters and getters in Android?" New topic
Author

performance overhead for setters and getters in Android?

x kevik
Greenhorn

Joined: Dec 17, 2012
Posts: 2
When I was learning Java standard edition, getter and setter functions were often used to hide variables and to reduce direct access to them. I have been told by several sources that in Android you should not use these functions and only modify the variables directly. The reason is that there is a performance loss due to overhead when using getters and setters is used in Android. Resulting in more memory use and slowing down the system.

Is there any truth to this? and if there is, why the performance loss for using getter and setter?
Will Zelan
Ranch Hand

Joined: Apr 15, 2012
Posts: 56

I don't think so. I really really don't think so.
If you're concerned about any possible performance or memory problem associated with getters and setters you'll probably want to write C++ code in the NDK.
Seriously though, you'll probably have a bigger performance hit showing something on the screen.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: performance overhead for setters and getters in Android?
 
Similar Threads
usage of "this"
Greetings!
uploading images and java