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
Ritik DwivediRitik Dwivedi 

please solve my problem

public class MessageMaker {
    public static string helloMessage() {
return ('You say "Goodbye," I say "Hello"'); 
        system.debug('You say "Goodbye," I say "Hello"');
    }
    

}
how to call this method in anonymous window???
Best Answer chosen by Ritik Dwivedi
SarvaniSarvani
Hi Ritik,

Call it as: Classname.methodname like below.
MessageMaker.helloMessage();
If you are getting errors for your code casue of unreacheble statement in line 4 you can try using below code:
public class MessageMaker {
    public static string helloMessage() {
       string Message= 'You say "Goodbye," I say "Hello"';
       return Message; 
          }
    
}

Call it as to see the output:
System.debug(MessageMaker.helloMessage());

Hope this helps! Please mark as best if it asnwers

Thanks

All Answers

SarvaniSarvani
Hi Ritik,

Call it as: Classname.methodname like below.
MessageMaker.helloMessage();
If you are getting errors for your code casue of unreacheble statement in line 4 you can try using below code:
public class MessageMaker {
    public static string helloMessage() {
       string Message= 'You say "Goodbye," I say "Hello"';
       return Message; 
          }
    
}

Call it as to see the output:
System.debug(MessageMaker.helloMessage());

Hope this helps! Please mark as best if it asnwers

Thanks
This was selected as the best answer
Ritik DwivediRitik Dwivedi
thanks 
its working
Telly UpdatesTelly Updates
Thanks Savarni It's also work for me 

Regards : https://tellyupdates24.com/