You need to sign in to do that
Don't have an account?
SuAk
static methods should be called with classname
Hi - If static methods should be called with class name and not with class instance, why does the Apex work book (Page 8 ) gives example to call static method with class instance.
Kindly clarify if my understanding of static methods should be called with class name is correct , and why apexworkbook is contradicting.
Thanks,
Kindly clarify if my understanding of static methods should be called with class name is correct , and why apexworkbook is contradicting.
Thanks,
i also review apex cookbook page no 8 and eveything is perfact looks there
look this here 2 method 1 is static sayYou() and one is non-static method sayMe()
and here is calling method code
Ref= https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex2_2.htm
here you see
call static method by
HelloWorld.sayYou();
and
call non-staic method by
HelloWorld hw = new HelloWorld();
hw.sayMe()
so here is clear that when call a static method use only className.staticMethod()
and when call a non-static method first create class instance and than call method by instance :)
solve
Thanks
Mark it best answer if it hepls you
Hi -
I get this error, when i try to execute..
HelloWorld hw = new HelloWorld();
hw.sayme();
Thanks
as apexwork book class page no 8 -:
look here no static keyword use in sayMe() method in apex workbook
if you clear about it Mark it best asnwer if it helps you :)