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
srinivas anantharamsrinivas anantharam 

how to execute static method

please tell me how to call sayYou method in bellow class?

public class HelloWorld{
    
    public static void sayYou(){
        system.debug('You');
    }
    
    public void sayMe(){
        system.debug('Me');
    }
}
Best Answer chosen by srinivas anantharam
Suraj GharatSuraj Gharat
HelloWorld.sayYou();

You may execute above statment anonymously in Developer Console or Workbench to call your static method.

All Answers

Neetu_BansalNeetu_Bansal
Hi,

In the constructor you can write, sayYou() like:

public HelloWorld()
{
sayYou();
}
Suraj GharatSuraj Gharat
HelloWorld.sayYou();

You may execute above statment anonymously in Developer Console or Workbench to call your static method.
This was selected as the best answer
test prashanth durgatest prashanth durga
thank you very much @Suraj Gharat, saved the day