0

I have a Apex class

public class Orignal{
    public static void exmapleFunc(String p1, String p2) {

        String strJSON = 'body';
            Example.exmapleFunc(p1, p2, strJSON, 'url','host');
    }
}

which has an function name exmapleFunc and another static class with the same function name , but the complier is giving me error

Method does not exist or incorrect signature: void exmapleFunc(String, String, String, String, String) from the type Example

even though the function does exists. Why am i getting this error? and can i resolve it without changing names?

Edit:

The Example class

public class Example{
    public static void exmapleFunc(String p1, String p2,String p3 , String p4 ,String p5) {
System.debug('im doing something useful');
    }
}
11
  • Your class is looking for emcampleFunc. Can you confirm if it's not a typo. Additionally, the error should also be point you to the line & file where error exists. Nov 19, 2021 at 7:37
  • 1
    You're getting the error becuase you're calling a method from the Example class, where is that class? Nov 19, 2021 at 9:00
  • 1
    @AkashJain, I don't see any issue in the classes and I am able to save them successfully. Can you let us know if you are not able to save the class or are you getting this when you are calling the class. If so let us know how you are calling this class. Nov 19, 2021 at 12:49
  • 1
    Works for me - I got "im doing something useful" in my debug log after calling Orignal.exmapleFunc('Blah', 'blah'); from Anonymous Apex. A) Are both of your classes within the same namespace? B) Are both top-level classes? (Because static can only be used on top-level methods.)
    – Moonpie
    Nov 19, 2021 at 12:50
  • 2
    C) Depending on where you are developing these, have you actually saved them or deployed them? (When working in VS Code, I have more than once saved a file then forgot to deploy it, and I have more than once deployed one that I thought I had saved but had not really saved.)
    – Moonpie
    Nov 19, 2021 at 13:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.