• Prashant Sniper
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
This is the challenge

Create an Apex class with a method that returns an array (or list) of strings.
Create an Apex class with a method 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
The method must accept an incoming Integer as a parameter, which will be used to determine the number of returned strings
The method must return a string value in the format Test n where n is the index of the current string in the array


This is my code.

public class StringArrayTest {

    public static List<String> generateStringArray (Integer n){
     List<String> Listresult = new List<String>();
        for (Integer i = 0; i <= n; i = i+1){
            Listresult.add('Test '+ i);  //there is a space between Test and i
            system.debug(Listresult[i]);
        }
      
     return Listresult;   
         
    }
        
}



I am able to execute the code but not able to complete the challenge.

I am executing  with this 

StringArrayTest.generateStringArray(3);

and i am getting following log

13:39:07:003 USER_DEBUG [7]|DEBUG|Test 0
13:39:07:003 USER_DEBUG [7]|DEBUG|Test 1
13:39:07:003 USER_DEBUG [7]|DEBUG|Test 2
13:39:07:004 USER_DEBUG [7]|DEBUG|Test 3


Please help 
Hi i am getting following error
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

This is my code.

public class StringArrayTest {

    public static List<String> generateStringArray (Integer n){
     List<String> Listresult = new List<String>();
        for (Integer i = 0; i <= n; i = i+1){
            Listresult.add('Test '+ i);  //there is a space between Test and i
            system.debug(Listresult[i]);
        }
      
     return Listresult;   
         
    }
        
}
This is the challenge

Create an Apex class with a method that returns an array (or list) of strings.
Create an Apex class with a method 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
The method must accept an incoming Integer as a parameter, which will be used to determine the number of returned strings
The method must return a string value in the format Test n where n is the index of the current string in the array


This is my code.

public class StringArrayTest {

    public static List<String> generateStringArray (Integer n){
     List<String> Listresult = new List<String>();
        for (Integer i = 0; i <= n; i = i+1){
            Listresult.add('Test '+ i);  //there is a space between Test and i
            system.debug(Listresult[i]);
        }
      
     return Listresult;   
         
    }
        
}



I am able to execute the code but not able to complete the challenge.

I am executing  with this 

StringArrayTest.generateStringArray(3);

and i am getting following log

13:39:07:003 USER_DEBUG [7]|DEBUG|Test 0
13:39:07:003 USER_DEBUG [7]|DEBUG|Test 1
13:39:07:003 USER_DEBUG [7]|DEBUG|Test 2
13:39:07:004 USER_DEBUG [7]|DEBUG|Test 3


Please help 
Hi i am getting following error
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

This is my code.

public class StringArrayTest {

    public static List<String> generateStringArray (Integer n){
     List<String> Listresult = new List<String>();
        for (Integer i = 0; i <= n; i = i+1){
            Listresult.add('Test '+ i);  //there is a space between Test and i
            system.debug(Listresult[i]);
        }
      
     return Listresult;   
         
    }
        
}