0
public class helloWorld2 {
    string firstName;
    string lastName;
    public static void Method1(string firstname){
        firstname='John';
        //lastName='Carter';
        system.debug(firstname);
    }
    public void method2(string lastname){
        //firstName='john';
        lastName='carter';
        system.debug(lastname);
    }
}

Anonymous Window:

Helloworld2 hw=new HelloWorld2();
hw.method2();

Error: Line: 2, Column: 4 Method does not exist or incorrect signature: void method2() from the type helloWorld2

1

When you want to call parameterized method, you need to pass parameters.

Helloworld2 hw=new HelloWorld2();
hw.method2('Smith');
4
  • public class helloWorld2 { string firstName; string lastName; public static void Method1(string firstname,string lastname){ system.debug('FirstName','lastName'); } public void method2(string firstname,string lastname){ system.debug('firstname','lastname'); } } error: Method does not exist or incorrect signature: void debug(String, String) from the type System can you please check this why cant we pass both – Venkatesh Jun 17 at 5:14
  • pass like this - method2('John', 'Smith'); – Ysr Shk Jun 17 at 5:15
  • Apex class is not saving its getting Error that Method does not exist or incorrect signature: void debug(String, String) from the type System – Venkatesh Jun 17 at 5:20
  • 1
    @Venkatesh System.debug takes exactly one parameter. You need two debug statements if you want to output two values. – sfdcfox Jun 17 at 5:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.