I am trying to learn Apex after spending a lot of time on Java and C++ in school. In a previous life I was a heavy user of SFDC and helped chose it for our org at the time. So Apex seems like a natural progression.
In that process I am trying to complete these "trailhead challenges". The first one is Create an Apex class that returns an array (or list) of strings:
- 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.
Code in the SFDC Developer console...
public class StringArrayTest
{
public static String [] generateStringArray(integer size)
{
String [] locStrArray = new String [size];
//set values in array...
for (integer i = 0; i < size; i++)
{
locStrArray[i] = 'Test ' + i;
}
//display array...
for (integer i = 0; i < size; i++)
{
System.debug(locStrArray[i]); //when in doubt, system out...
}
return locStrArray;
}
}
Code In the Open Execute Anonymous Window...
integer size =10;
String [] strArray = new String [size];
strArray = StringArrayTest.generateStringArray(size);
for (integer i = 0; i < size; i++)
{
strArray[i] = 'Test ' + i;
system.debug('B ' + strArray[i]); //when in doubt, system out...
}
Here is what appears to be the access violation I am getting...
Line: 3, Column: 28
Method is not visible: void StringArrayTest.generateStringArray(Integer)
This thing works in Netbeans with system.debug() being replaced by system.out.println()
This challenge might not even be valid anymore as I started it last spring then put it down til now. Mostly I am just trying to understand the behavior of their online IDE relative to the quirks other IDEs have. This seems like a pretty simple program that should be pretty straight forward. Is there a background rule at work?