Skip to main content
Vishal Singh が「#Apex」で質問

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);
2 件の回答
  1. 2023年10月9日 6:16

    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!
0/9000