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
sirishanekkanti06sirishanekkanti06 

why we are creating static method under apex class using the developer console.

i dont know why we are creating static method under apex class using the developer console.what is the purpose of creating static method undre the apex class...please help..

Best Answer chosen by Admin (Salesforce Developers) 
Laxman RaoLaxman Rao

When we declare a method or variable as static, it's initialized only once when a class is loaded.
A static method or variable does not require an instance of the class in order to run.
Static methods are generally used as utility methods and never depend on a particular instance member variable value. Because a static method is only associated with a class, it cannot access any instance member variable values of its class.

 

All Answers

Laxman RaoLaxman Rao

When we declare a method or variable as static, it's initialized only once when a class is loaded.
A static method or variable does not require an instance of the class in order to run.
Static methods are generally used as utility methods and never depend on a particular instance member variable value. Because a static method is only associated with a class, it cannot access any instance member variable values of its class.

 

This was selected as the best answer
sirishanekkanti06sirishanekkanti06

thanku for your solution...