You need to sign in to do that
Don't have an account?
Shilpa Srikantachar
Method does not exist or incorrect signature: error
Hi All,
I'm a beginner in Development and trying to execute few example programs
public class Static_Example {
public static Integer aval=0;
public Integer bval =0;
public void add(){
aval=aval+10;
bval=bval+10;
}
}
public class Static_Example {
public static Integer aval=0;
public Integer bval =0;
public void add(){
aval=aval+10;
bval=bval+10;
}
}
Error :
Line: 3, Column: 6
Method does not exist or incorrect signature: void add() from the type Static_Example
Please let me know the mistake I have done.
Thanks
Shilpa
I'm a beginner in Development and trying to execute few example programs
public class Static_Example {
public static Integer aval=0;
public Integer bval =0;
public void add(){
aval=aval+10;
bval=bval+10;
}
}
public class Static_Example {
public static Integer aval=0;
public Integer bval =0;
public void add(){
aval=aval+10;
bval=bval+10;
}
}
Error :
Line: 3, Column: 6
Method does not exist or incorrect signature: void add() from the type Static_Example
Please let me know the mistake I have done.
Thanks
Shilpa
Your code looks good. If you are trying to directly execute Static_Example.add() you will get this error. Since you have non static method add() in your class you need to first istantiate your class and call your method.
Try Executing below in your Execute Anonymus window to run your class: Please refer below link:
https://www.sfdc99.com/2015/01/22/introduction-to-the-static-keyword/
Hope this helps. Please mark as best answer if it does.
Thanks
Hope you have apex class named Static_Example with method add() in your code as below
And trying to execute the below code in your anonymus window: It should work fine with no errors I have tested in my org. Please paste your apex class code and lines your trying to execute in anonymus window if your still facing the problem. Because your error says line 3
Error :
Line: 3, Column: 6
Method does not exist or incorrect signature: void add() from the type Static_Example
Where you only have 2 lines in you anonymus window if your trying the same.
Hope this helps!
Thanks
Thank you for taking the time and trying it out before answering .
However , this is the execution that I am trying and getting an error .
Static_Example one =new Static_Example();
Static_Example two =new Static_Example();
one.add();
System.debug('Aval:'+Static_Example.aval);
System.debug('One :Bval:'+one.bval);
System.debug('Two :BVal:'+two.bval);
two.add();
System.debug('Aval:'+Static_Example.aval);
System.debug('One :Bval:'+one.bval);
System.debug('Two :BVal:'+two.bval);
Execute Anonymous Error :
Line: 3, Column: 5
Method does not exist or incorrect signature: void add() from the type Static_Example
Thanks
Shilpa
Please find the APEX class .
Regards
Shilpa
Unfortunately. I am unable to replicate the issue with the codes above. Its working fine for me. I understand you are trying to know the difference between using and not using static keywords for the method. I suggest you to try the same example in different new org and test. It might be because of existing classes some times.
Hope this helps!
Thanks,
Sarvani