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
Abhinav Sharma 207Abhinav Sharma 207 

Method does not exist or incorrect signature: void mainValue() from the type PassBy

Hi All,

I am trying to run this code:
public class PassBy {

    public void mainValue() {
        String url = 'www.one.com';
        System.debug('Before Value Call : '+ url );
        passByValue(url);
        System.debug('After Value Call : '+ url );
        
    }
    
    private void passByValue(String NewUrl)(){
        NewUrl = 'www.two.com';
        System.debug('Inside change'+NewUrl);
    }
}




---------------------------------

PassBy p = new PassBy();
p.mainValue();

---------------------------------------------

Getting below error:
Method does not exist or incorrect signature: void mainValue() from the type PassBy
CharuDuttCharuDutt
Hi Abhinav
Try Below Code
Made Some Changes There's Extra '()' In Your passByValue Method
public class PassBy {

    public void mainValue() {
        String url = 'www.one.com';
        System.debug('Before Value Call : '+ url );
        passByValue(url);
        System.debug('After Value Call : '+ url );
        
    }
    
    private void passByValue(String NewUrl){
        NewUrl = 'www.two.com';
        System.debug('Inside change'+NewUrl);
    }
}

Please Mark It As Best Answer If It Helps
Thank You!

Suraj Tripathi 47Suraj Tripathi 47
Hi,

Please change below code:-
private void passByValue(String NewUrl){
        NewUrl = 'www.two.com';
        System.debug('Inside change'+NewUrl);
    }
Please mark it as Best Answer if it helps you.

Thanks & Regards
Suraj Tripathi
sakhisakhi
Try this
 
public class PassBy {

    public void mainValue() {
        String url = 'www.one.com';
        System.debug('Before Value Call : '+ url );
        passByValue(url);
        System.debug('After Value Call : '+ url );
        
    }
    
    private void passByValue(String NewUrl){
        NewUrl = 'www.two.com';
        System.debug('Inside change'+NewUrl);
    }
}




---------------------------------

PassBy p = new PassBy();
p.mainValue();

---------------------------------------------