Skip to main content
Vishal Singh perguntou em #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 respostas
  1. 9 de out. de 2023, 06: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