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
Prashant SniperPrashant Sniper 

Hi i am getting error for apex

Hi i am getting following error
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

This is my code.

public class StringArrayTest {

    public static List<String> generateStringArray (Integer n){
     List<String> Listresult = new List<String>();
        for (Integer i = 0; i <= n; i = i+1){
            Listresult.add('Test '+ i);  //there is a space between Test and i
            system.debug(Listresult[i]);
        }
      
     return Listresult;   
         
    }
        
}
Martha VMartha V
to excecute it are you writing the following?

List<String> myStringArray = StringArrayTest.generateStringArray(x);        //where x is a defined number
Prashant SniperPrashant Sniper
Hi ,

Thanks for your reply

I am able to execute the code but not able to complete the challenge.

I am executing  with this 

StringArrayTest.generateStringArray(3);

and i am getting following log

13:39:07:003 USER_DEBUG [7]|DEBUG|Test 0
13:39:07:003 USER_DEBUG [7]|DEBUG|Test 1
13:39:07:003 USER_DEBUG [7]|DEBUG|Test 2
13:39:07:004 USER_DEBUG [7]|DEBUG|Test 3



but when trying to check the challenge  i am getting this message

 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.'