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
Jim ErenzoJim Erenzo 

Trailhead First Apex Challenge problem: No Apex class named 'StringArrayTest' was found

I keep getting this error from the challenge.  I logged into my developer console from the Trailhead challenge screen using same email address (only have one on Salesforce.com) and nothing has changed since I started the developer track on Trailhead, which requires numerous challenges.

The Apex class named StringArrayTest shows up on the development console and from the setup interface in the developer section....

I am puzzled how it can show up on both and after entering from the trailhead challenge logon to developer edition and still have this error that is is not  found.  Any suggestion????
Shyama B SShyama B S
Hi Jim,
The below is my StringArrayTest class which worked. Please check if they are the same.

User-added image

Thanks,
Shyama
Jim ErenzoJim Erenzo
Hi,
Thanks for the input.  I just re-wrote the code as there are many versions on the forum.  However, I got the same error.

Error while checking challenge using below (and other versions) of the code.... ---------

"Challenge not yet complete... here's what's wrong: 
No Apex class named 'StringArrayTest' was found" 

Code from Apex Class-------

public class StringArrayTest {
    
    public static String[] generateStringArray (Integer n){
        String[] arrayList=new String[]{};
            for (integer i=0;i<n;i++){
                arrayList.add('Test' +i.format());
        }
        displayString(arrayList);
        return arrayList;
    }
 
    private static void displayString(String[] arrayList){
        for(integer i=0;i<arrayList.size();i++){
            System.debug('hello');
            System.debug(arrayList[i]);
        }
        }
    }
Amit Chaudhary 8Amit Chaudhary 8
Please find below a little fix for your issue.

The problem was the space between Test and the number you had : Test0, Test1.... and what was necessary was Test 0, Test 1, ... 
 
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

Thanks
Amit Chaudhary
Jim ErenzoJim Erenzo
Hi Amit - Thanks for the feedback.  
However, that did not resolve the problem.  Again, the result after testing the results was that it could not find the Apex class.  I did not get a problem type error in the programming and worked thos nuances out...  I am not sure why it is not able to see the Apex class StringArrayTest since it is saved in my Apex Developer consule and I can see it from my setup menu developer Apex Classes....

Any help is appreciated.
Amit Chaudhary 8Amit Chaudhary 8
Please check your apex class in Setup->Apex Classes.?
Jim ErenzoJim Erenzo
Hello Amit
Yes it shows up in the Setup>Apex classes
Amit Chaudhary 8Amit Chaudhary 8
If possible then please share you user name and password on my email id i will check.
amit.salesforce21@gmail.com
Amit Chaudhary 8Amit Chaudhary 8
Please try below code.
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;
    }
}
Will resolve your issue.

 
Sandeep BhanotSandeep Bhanot
Jim - can you also please confirm that your DE Org doesn't have a namespace? Thanks
Sandeep
Jim ErenzoJim Erenzo
Hello Sandeep, I'm not sure where the namespace would be to verify...?
Madeline LittleMadeline Little
I'm having this same issue now.  The challenge is telling me that the class doesn't exist, despite the fact that I'm currently looking at it sitting in my Apex classes. 
Ishwarya Ramachandran 6Ishwarya Ramachandran 6
I am having the same issue as Jim! Please let us know if you have any solution!
Fayazuddin MohammedFayazuddin Mohammed
Hello, Can anyone please tell me what's wrong with my code. When I run it executes fine and o/p also seems to be correct. Howeve the trailhead challenge shows error "Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings."

public class StringArrayTest {
    public static List <String> generateStringArray(Integer n) {
        List<String> numbers = new List<String>();
        
        for (integer i=0;i<=n; i++){
              numbers.add('Test '+String.valueOf(i));
            System.debug(numbers[i]);            
                }
        return numbers;
    }
}
 
Amit Chaudhary 8Amit Chaudhary 8
Your For loop should be like below

for(Integer i=0;i<n;i++)

NOTE :- It shoud be < n not <=n
pratibha sundar sundaramoorthypratibha sundar sundaramoorthy
Hi, I'm a newbie. I'm getting the same error. Not only for this, for all challenge involving hands on, like EmailManager or StringArrayTest or Opportunities By Stage, it is not able to find my data. What am I missing??
venkatesh puttamvenkatesh puttam
Public class StringArrayTest {
    Public Static List<String> genarateStringArray(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;
    }
}
David AlevyDavid Alevy
The following worked for me.  Select your name at the top right of the Salesforce screen -> Select "Settings".  Make sure that the default is set to the "Developer Edition" that you use and not the "Trailhead Playground".  
ANSUMAN PANDA 8ANSUMAN PANDA 8
Even I was having the same issue. It was because I had chosen incorrect org under the hands on the challenge.
I had developed the class in my developer org but was trailhead was set to trailhead playground.