You need to sign in to do that
Don't have an account?
animesh singh
I am getting same problem even if my output is correct
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;
}
}
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;
}
}
All Answers
Thanks for your help.
I am facing similar issue and don't know where the problem is.
Error :
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.
Code:
public class StringArrayTest {
public static list<string> generateStringArray(Integer i)
{
List<String> myArray= new List<string>();
for(Integer k=0;k<=i;k++)
{
myArray.add('Test '+k);
system.debug(myArray[k]);
}
return myArray;
}
}
The code is running fine when I run it.
Kindly help.
Regards,
Satya
Please change your method to public static String[] generateStringArray(Integer i) { ... } and see if that works.
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]);
}
Try removing n from this statement: List<String> str = new List<String>(n);
It should work.