function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
L3nL3n 

No Apex class named 'StringArrayTest' was found

Hi, Can you please help.
I'm working on this Trailhead challenge:
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.

This following is my code sample:
public class StringArrayTest {

    // Public method
    public static List<String> generateStringArray(Integer numTests) {
        // Create a list
        List<String> Tests = new List<String>();
        for (Integer i=0; i<numTests; i++){
            Tests.add('Test '+ i);
            system.debug(Tests[i]);
        }
        
	return Tests;
    }
}

The test command is:
StringArrayTest.generateStringArray(7);

and the result I see is:
User-added imageI don't understand why the trailhead is saying:
Challenge not yet complete... here's what's wrong: 
No Apex class named 'StringArrayTest' was found

I even tried logging out and back in again.
 
Amit Chaudhary 8Amit Chaudhary 8
Please try to delete your class and again create same class.
public class StringArrayTest {
    
    public static List<String> generateStringArray(Integer n)
    {
        List<String> myArray = new List<String>();
        for(Integer i=0;i<n;i++)
        {
           myArray.add('Test '+i);
           System.debug(myArray[i]);
        }
        return myArray;
    }
}

Please let us know if this will help you