You need to sign in to do that
Don't have an account?
Getting Started with Apex Challenge
I'm not sure where I am going wrong. Any help would be appreciated.
Here is my code:
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.
Here is my code:
public class StringArrayTest { public static String[]generateStringArray(){ List<String> Test = new List<String>{'Test 0', 'Test 1', 'Test 2'}; for(Integer n=0; n<Test.size(); n++){ System.debug('Test' + n); } return Test; } }This is the 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.
and make sure Test has a space in it like 'Test ' + n
Try this:
thx.
All Answers
and make sure Test has a space in it like 'Test ' + n
Try this:
thx.
Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...).
The length of the array is determined by an integer parameter.
The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings.
Each string must have a value in the format 'Test n' where n is the index of the current string in the array.
The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.
this is method used by another class
for example
I can code StringArrayTest.generateStringArray(10) and this will return a list of string
Test 0,
Test 1,
...
Test 6
Test 7
etc.
This is how you can code utility methods/helper methods.
Thx
System.debug(StringArrayTest.generateStringArray(10));
Thx