+ Start a Discussion

Can any one help me on this....

the challenge is ,

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.

and the code i tried is...
Public class StringArrayTest 
public  static void generateStringArray ( String test)
String[] testnum = new String{'test 1','test 2'};

for(Integer i=0;i<testnum.size();i++)
    System.debug(testnum [i]);

return generateStringArray 

please correct me...
Best Answer chosen by NAVEEN KUMAR
Himanshu ParasharHimanshu Parashar
Hi Naveen,

It should go like this.
public class StringArrayTest{

    public static String[] generateStringArray(integer sizeoflist)
        List<String> lst = new List<String>();
        for(integer i=0;i<sizeoflist;i++)
         lst.add('Test ' + i);
        return lst;