• Arunkumar Pandyan Ramar
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi,

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 as shown below.

public class StringArrayTest {
    
    public static List<String> generateStringArray(Integer n){
        List<String> str = new List<String>(n);
        for(Integer j=0;j<n ;j++){
           str.add('Test '+String.valueOf(j));
          }
        return str ;
    }
}

When I test this on the debug-->open  execute anonymous window,

with the following code, it runs successfully.

List<String> ls = StringArrayTest.generateStringArray(10);
for (Integer m=0;m<10;m++){
    System.debug(ls[m]);
}
 
I am getting the following error message

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 as shown below.

public class StringArrayTest {
    
    public static List<String> generateStringArray(Integer n){
        List<String> str = new List<String>(n);
        for(Integer j=0;j<n ;j++){
           str.add('Test '+String.valueOf(j));
          }
        return str ;
    }
}

When I test this on the debug-->open  execute anonymous window,

with the following code, it runs successfully.

List<String> ls = StringArrayTest.generateStringArray(10);
for (Integer m=0;m<10;m++){
    System.debug(ls[m]);
}
Hi,

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 as shown below.

public class StringArrayTest {
    
    public static List<String> generateStringArray(Integer n){
        List<String> str = new List<String>(n);
        for(Integer j=0;j<n ;j++){
           str.add('Test '+String.valueOf(j));
          }
        return str ;
    }
}

When I test this on the debug-->open  execute anonymous window,

with the following code, it runs successfully.

List<String> ls = StringArrayTest.generateStringArray(10);
for (Integer m=0;m<10;m++){
    System.debug(ls[m]);
}
 
public class StringArrayTest{
    public static List<String> generateStringArray(Integer n){
    List<String> lstString = new List<String>();
     for(Integer i=0; i<n;i++){
         lstString.add('\'Test '+i + '\'');        
     }
        System.debug('__________'+lstString);
        return lstString;
    }   
}