- Home /
Question by
Rodolfo-Rubens · Aug 29, 2013 at 07:24 PM ·
variablespublicprivatevs
How faster is private variables over public variables?
Just wondering, I'm afraid to need to rewrite parts of my code just because I'm decreasing the performance due to my variables. In the end, does it matter? I mean, if I'm able to declare all my variables to private VS. if I declare all my variables to public, it would make a huge difference?
Comment
Best Answer
Answer by Hoeloe · Aug 29, 2013 at 07:50 PM
It has no effect on execution speed. The modifiers private
and public
are very high-level, and are only used by the compiler when the code is actually being compiled. In general, it is a good idea to keep as many variables as possible private, not for performance reasons, but to prevent them from being modified accidentally.