+ Start a Discussion
sfdc18sfdc18 

Getting Method does not exist or incorrect signature error for List remove() method

Hi,

I am getting error for list remove() method.

Error :
Compile Error: Method does not exist or incorrect signature: [List<Services_and_Equipment__c>].remove(Services_and_Equipment__c)


I am comparing two lists. Based on some condition adding the values in new list.
I want to then remove these values from older list (the values which are added to new list).
Below is the code.
for(Services_and_Equipment__c varAdd : lst_Add_SE) {
    for(Services_and_Equipment__c varDisc : lst_Disconnect_SE) {
       if(varAdd.Services_and_Equipment_Name__r.Service_Type__c 
          ==  varDisc.Services_and_Equipment_Name__r.Service_Type__c) {
                     lst_AddDisconnect_SE.add(varAdd); 
                     lst_AddDisconnect_SE.add(varDisc); 
                     lst_Complex_SE.remove(varAdd);  
                     lst_Disconnect_SE.remove(varDisc);
       }                        
    }     
}
Thanks.

 
Rajnish Bishnoi 13Rajnish Bishnoi 13
remove method of list always require index of the element.
So first you need to get index of that element and then call remove method.
remove(index)

Thanks,
Rajnish
Rajnish Bishnoi 13Rajnish Bishnoi 13
Hi,

Do you got resolved your problem.
If yes please have this as best answer so that other can see it.