That error is the grader checking your StringArrayTest class, and 'does not return the proper number of strings' means the count is off. Check these:
1. The method is public static and returns a List of String: public static List<String> generateStringList(Integer n)
2. It returns exactly n items - the usual slip is the loop bounds. Use for (Integer i = 0; i < n; i++) - start at 0, strictly less-than n. Using i <= n gives n+1 items; starting at 1 gives n-1 - either one trips 'proper number of strings.'
3. Each item is 'Test ' + i (with the space, index starting at 0), so the list is 'Test 0', 'Test 1', up to 'Test ' + (n-1).
4. The class is named exactly StringArrayTest.
Minimal version:
public class StringArrayTest {
public static List<String> generateStringList(Integer n) {
List<String> myList = new List<String>();
for (Integer i = 0; i < n; i++) { myList.add('Test ' + i); }
return myList;
}
}
Save, then re-run Check Challenge.
If this helps, please mark it as the Best Answer so it helps the next person - thanks 🙂
1 respuesta