reate an Apex class with a method that returns a list of strings
Create an Apex class with a method that returns a list of formatted strings. The length of the list is determined by an integer parameter. You can also use an array if you prefer, but these instructions assume you’re using a list.
- 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 a 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 list of strings. Each element in the list must have the format Test n, where n is the index of the current string in the list. For example, if the input is 3, then the output should be ['Test 0', 'Test 1', 'Test 2']. Remember that in Apex, the index position of the first element in a list is always 0.
---
File ->new -> Apex Class
public class StringArrayTest {
public static List<String> generateStringArray(Integer n){
List<String> test = new List<String>();
for(Integer i=0; i<n; i++){
test.add('Test '+i);
system.debug(test[i]);
}
return test;
}
}
디버그하기
Debug -> Exter Apex Code
StringArrayTest.generateStringArray(3);
Debug only 만 누른다면
오류
Method does not exist or incorrect signature: void generateStringArray(Integer) from the type StringArrayTest
-> 저장을 안해줘서 생기는 문제! 컨트롤 S로 저장해주자
좋아요공감
공유하기
통계
게시글 관리