+ Start a Discussion
vinod Sanubalavinod Sanubala 

Get Started with Apex in trail head

Hi Al,

I am trying the module in TrailHead, "Get Started with Apex" from Developer Beginner

I have built below code, its working as expected, however I am getting error:
public class StringArrayTest {
    public static void generateStringArray(Integer counts){
        list <integer> results = new list<integer>(counts);
        for(Integer i=0; i< results.size(); i++)
            system.debug('Test '+i);

Error Message:

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.

Thanks in advance.

Raj VakatiRaj Vakati
Use this code
public class StringArrayTest {
        public static String[] generateStringArray(Integer length) {
        String[] myArray = new List<String>();
        for(Integer i=0;i<length;i++) {
           myArray.add('Test ' + i);

        return myArray;

And  go to Your Name>Developer Console>Debug>Open Execute Anonymous Window 
Paste below code in it

list<string> myArray = StringArrayTest.generateStringArray(10);

Then verify the challange 

Raj VakatiRaj Vakati
vinod Sanubalavinod Sanubala
Thanks for your help Raj, did work,