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
Deepika GhoseDeepika Ghose 

Getting this error in challenge:

Challenge Not yet complete... here's what's wrong:
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

My code is:
public class StringArrayTest {
    public static List<String> generateStringArray(Integer l)
     List<String> a1=new List<String>();
            a1.add('Test '+i);
        return a1;

m executing through
StringArrayTest em = new StringArrayTest();

Can anyone help me whats wrong I did here?
Ajay mishraAjay mishra
Hi Deepika,

Can you share challenge description.

Ajay Mishra
hi Deepika Ghose 

try below code 
public class StringArrayTest { 
   public static List<String> generateStringArray(Integer n) { 
    List<String> myArray = new List<String>(); 
     for(Integer i=0;i<n;i++) {
       myArray.add('Test '+i); 
       System.debug(myArray[i]); } 
        return myArray; 

Mark it best answer if it helps you :)
Ajay mishraAjay mishra
Hey Deepika,

As mention in Challenge String should be returned in this format 'Test n'.

You are missing the spcae in between them. Please add a space in front of 'Test'.

Your Challenge will be completed.

Ajay Mishra
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for same issue

Problem in your code is that you need to pass one space between 'Test '+i and you need to start loop from zero

Please try below code:-
public class StringArrayTest {
        public static String[] generateStringArray(Integer length) {
        String[] myArray = new List<String>();
        for(Integer i=0;i<length;i++) {
           myArray.add('Test ' + i);

        return myArray;
And go :
Your Name>Developer Console>Debug>Open Execute Anonymous Window 
Paste below code in it
list<string> myArray = StringArrayTest.generateStringArray(10);
Please let us know if this will help you