1 Reply Latest reply: Apr 2, 2008 5:44 PM by 807591 RSS

    Initiating static fields, and adding to a static array

    807591
      I have some fields that I declare in my class out of any methods like this:
      public class SObject
      {
      
           public static final SObjectType NONE = new SObjectType("None", new None());
           
           public SObject()
           {
                ...
      In the Class SObjectType I have an array that is the same way
      public class SObjectType
      {
           public static ArrayList<SObjectType> sObjects = 
                new ArrayList<SObjectType>();
           
           public SObjectType(String name, SObject example)
           {
                      sObject.add(this);
                      ...
      Then in the actual constructor of SObjectType I add the constructed SObjectType to this array sObjects, as seen here. But then when I use sObjects later it says that nothing was added.
      Why does this happen? Is it just impossible to add things to arrays when initializing fields like this?

      Edited by: happypigface on Apr 2, 2008 3:22 PM