You need to sign in to do that
Don't have an account?
Method does not exist or incorrect signature: void returnAverageSum(List<Opportunity>) from the type PracticeApex
Hi All,
I am getting error:
"Method does not exist or incorrect signature: void returnAverageSum(List<Opportunity>) from the type PracticeApex" . Kindly help me in resolving above error.
Here is my code
public class PracticeApex{
public static void retrunAverageSum(List<Opportunity> ol){
Integer avg=0;
Integer sum=0;
Integer size= ol.size();
for(Opportunity o: ol){
sum=sum+o.Amount.IntValue();
}
avg=sum/size;
System.debug(avg);
}
}
from Dev Console:
PracticeApex pa=new PracticeApex();
List<Opportunity> opp=[Select Id, Amount from Opportunity];
pa.returnAverageSum(opp);
Hi Vishal,
1. Typo Mistake : Your method name is retrunAverageSum and you are calling returnAverageSum in Dev Console.
2. Remove static keyword from method.
Hope this will help.
Thanks!
Hey Vishal,
I've faced a similar issue before, and it took me a bit of time to figure it out. In your case, the error is indicating that there's no method with the signature void returnAverageSum(List<Opportunity>) in your PracticeApex class.
I once encountered a similar issue where my method signature wasn't matching the one in the class calling it. It turned out that I had a typo in the method name. So, let's check for any typos first.
Looking at your code, it seems like there's a typo in your method declaration. You have defined the method as retrunAverageSum instead of returnAverageSum. Typos can be tricky to spot, so it's always good to have an extra set of eyes.
Here's the corrected code:
Give this a try, and hopefully, it resolves your issue. If the problem persists, another thing to check is whether the Amount field is correctly spelled and capitalized in the Opportunity object.
Also, when I faced a complex issue, I found it helpful to consult the Salesforce developer documentation and sometimes seek guidance from a consulting services company. They can provide valuable insights and solutions. Salesforce's developer community is fantastic, and the resources available there can be a great help too.
Hope this helps! Let me know how it goes.