Skip to main content
In the introduction to Apex, I was surprised that the challenge was such a leap for an introductory lesson, but I never back away from a challenge.  I have attempted to create the class which requires much more knowledge than is presented.  The method is to be public and static.  But the complier message says that constructors cannot be static.  I see no reason why my method should be interpreted to be a constructor. Can anyone suggest why this is happening.  I'm a Newbie, so it could be a simple correction, but I have done some extensive research before asking for assistance.  Thanks in advance.

Task "Create an Apex class that returns an array (or list) of strings"
3 answers
  1. Apr 15, 2015, 3:30 AM

    Hello Bob,

    This is my first attempt at Apex code. My error is indicated on line 4, and the error text is ³Constructors cannot be static².

    As the challenge indicates that the method must be static and I believe that

    I have what is a return type, I am confused as to why I am receiving this

    error.

    Again, this is my first attempt, so the problem may be a very simple

    ³beginners² error. Thanks.

    public class StringArrayTest {

    // Public method

    public static generateStringArray(Integer arrSize) {

    List testNum = new List(arrSize);

    for (Integer n=0;n

0/9000