You need to sign in to do that
Don't have an account?
Prashant 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;
}
}
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;
}
}
List<String> myStringArray = StringArrayTest.generateStringArray(x); //where x is a defined number
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.'