You need to sign in to do that
Don't have an account?
Arunkumar Pandyan Ramar
error message : generateStringArray method failed while doing the Apex module exercise in trailhead
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]);
}
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]);
}