function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

When to use static method/variable and when to not?

What is the advatages of using static method/variables beside of it can be call even not instantiating the class where they reside?


There is a great book out called 'Advanced Apex Programming' by Dan Appleman that devotes a whole chapter to static techniques.  The are useful in maintaining data across trigger calls, caching data, controlling program flow. 

farukh sk hdfarukh sk hd
Static variable are global variable which are not related to particular object,You can call a static variable directly by class name without requiring instance of class similar goes for static methods.

For static variable and static method concept in detail visit,