Singleton Vs Static Class

Hi,
Kindly excuse if my question annoys anyone in the forum.
Compared to a singleton class we can always have a class and all methods as static?
Wouldnt that be the same as Singleton.
Also looking at Runtime class, its a Singleton. Just thinking if Runtime class could be a class with this static methods instead of making the constructor private .

I thought I read somewhere that however you implement your singletons, client code shouldn't break if later you decide that you don't need/want a singleton for that class anymore.I agree with that principle.
This requires that the client code never calls the getInstance() method, and the best way to make sure of that is that the client code does not depend on the singleton class, but on an interface that the singleton class implements.
(Speaking for myself, I can assure you that I never thought that deeply about it, but continuing...)I have thought a lot about Singletons, specifically when contemplating flaying myself alive for putting them prematurely where they weren't really needed (not to mention some of my colleagues' choice, for fear my message would deserve editing out by moderators).
I have come to the conclusion that Singleton is overhyped, probably because it's one of the simplest patterns, and the first one people are taught as a way to illustrate the very concept of "design pattern". And overused because it feels so natural to use the first and simplest pattern one has learnt.
I'm not claiming Singleton has no merits (I used to claim that on this forums). I'm claiming most usages I've seen of Singleton were not based on a careful consideration of the real merits.
If we implement our singletons (who have state) as "static classes", aren't we violating this?Ah, OK, I get it now: if someday you need to have several copies of the states with different values, you could always "de-singletonize" the singleton, with minimal impact for properly-written client-code, as you point out, whereas you couldn't justas easily "de-staticize" the static calls.
Indeed that's an argument when evaluating whether making a method static: it statically (1) binds the client code to the implementation class.
(1) not a pun, merely the very justification for the term static as a keyword.
J.

Similar Messages

  • Singletons and Static class behavior

    Hi all and thanks for taking a look at this,
    I was playing around with a Singleton class today and it raised raised a few questions around Static methods in the singleton. When my class is instatiated I load some data into a HashMap map that I want to make available for read only purposes through other methods in my singleton.
    I really wanted to just call a static method to look up the value, so I followed the standard model. I had a private static HashMap that is loaded with data when the Contructor is called from the getInstance(). I included the standard model example for you if you wanted to refer to it.
    I ran my code making a static MyClass.getData() call to see what would happen. The static call did not return a value, I wasn't surprised. Then I added a call to MyClass.getInstance() followed by the static MyClass.getData() call and this returned the appropriate value.
    Then I changed my Singleton as follows and was wondering if there were any issues that might result because of this and I was wondering what the process that is followed by java when calling a static method (what does it use, where does it look).
    My Code:
    public class MyClass {
    private static MyClass instance;
    private static HashMap myData;
    private MyClass() {
    myData = new HashMap();
    myData.put("1", "value 1");
    myData.put("2", "value 2");
    private static synchronized void getInstance() {
    if (instance == null)
    instance = new MyClass();
    public static String getData(String key) {
    if (myData == null)
    getInstance();
    return (String)myData.get(key);
    The standard singleton model class:
    public class MyClass {
    private static MyClass instance;
    private MyClass() { }
    public static synchronized MyClass getInstance() {
    if (instance == null)
    instance = new MyClass();
    return instance;
    ... rest of methods (not static)
    }

    Thanks for the reply,
    Really my only reason for making it static was so the calling class would not have to get a handle to the actual MyClass Instance. Therefore avoiding the Synchronization method.
    I was attempting to aviod the famous broken double check locking by having the checks in different methods. I am assuming from you warning that keeping the methods seperate and synchronizing the getInstance is really no different than putting a synchronize(this) block around the second check and the constructor call?
    Really my objective is to retrive data once, not really create a single access point for getting the data. As an alternative, I tried the following code and it seems to work, any issues you can see with this?
    public class MyClass {
    private static HashMap hm;
    static {
    hm = new HashMap();
    // code to get Data into HashMap
    public static String getData(String key) {
    return hm.get(key);

  • Singleton Vs Static Classes

    What is the Difference b/w implementing a singleton pattern and
    making a class Static?

    If you implement a (the?) singleton pattern, references to the resulting
    object can be passed around as method arguments, and it can
    belong to a class which implements useful interfaces or extends
    some useful base class.

  • Design Pattern: Is the Universe Object a Singleton or Static or either way.

    Hi All,
    1. I've read this thread: static versus singleton
    http://forum.java.sun.com/thread.jsp?forum=425&thread=401035&tstart=105&trange=15
    2. Now, specifically if you were to model the Universe Object, what would you choose? a Singleton
    or a Static Class or either way depending on your design point of view?
    (either way depending on your design point of view imply there is more than one solution to a problem.)
    Basically, I'm looking for is the justification of one (singleton) or the other (static) or doesn't matter
    in addition to the pure technical pros and cons (or avantage/disavantage) of singleton versus Static (see pt. 1)

    <dubwai>
    What's 'the Universe Object'?
    </dubwai>
    Sorry, for not being clear. My assumption is that every body would undertand the word 'Universe' immediately. So with this clarification. I hope you will have more input. Thanks.
    public class Universe //Singleton
         private static Universe instance = new Universe(); 
         private Universe()
         public static Universe getInstance() 
           return instance;
         public void do() 
    public class Universe  //Static Class like Math class for example
         public static void do() 
         ...all other methods are static
    <os>
    Personally, I'd make the universe a singleton.
    The universe is an 'object', not a class, and if alternate universes are proved to exist you can create new instances,
    and not treat it as a singleton any more, without much rewriting (a static implementation would need a total rewrite).
    </0s>
    1. Keywords: Personally and alternate universes are proved to exist.
    Yes, this is the kind of reasoning I'm looking for. By that I mean when we design a class, our reasonning should not depends
    on the 'pure' technical concepts of what Singleton class or Static class can do but rather depending on the reality
    of the world. And then from that understanding we would choose a Singleton or Static class. This is what I meant by 'Either way, it doesn't matter' which depend on one's view about of existence of the universe whether it's unique or not. In your case (Os), you prefer Singleton because of the possibility of alternate universes.
    2. Now, let's admit, there is only one Universe, would you still prefer Singleton class over Static class? for all the techincal reasons that you said
    "As a singleton,..."
    "It would also probably be useful to treat the universe as a generic Object..."
    OR just because a Singleton would be 'safer' to cover the possibility of design extension in that can cover all cases (alternate as well)

  • Singleton instance vs static class

    Hi,
    I often got confused to identify when is better to use a singleton instance and when is better use a static class insted.
    Could someone please advise what criteria should be observed to decide which way is better?
    Thanks in advance,

    A class with all static methods generally connotes a helper class that supplies behavior or enforces business rules of other objects. A class with only state and no behavior is typically encountered in distributed systems, also known as a transfer object. Most true objects have both state and behavior. A singleton is simply a normal object that ensures only a single instance of itself will ever be created and returned for use to a caller.
    - Saish

  • Singleton pattern class and static class

    Hi,
    what is difference between the singleton pattern class and static class ?
    in singleton pattern, we declare a static member[which hold one value at a time] ,static method[ which return static member value] and a private constructor[not allow to direct instantiation]. My words are -- as a singleton pattern we implement static class .
    so can we say a singleton pattern is static class it means both are same or is any difference between these two ??

    malcolmmc wrote:
    On several occasions I've had to convert a static (never instanceated) class to a singleton type, for example because I realise I need an instance per thread, or I decide to make a program more modular, with more than one configuration.
    I've never done the opposite.
    So generally I favour the singleton if there any "state" involved, because it's more flexible in unanticipated directions. It also gives extra flexibility when building tests, especially if you program to an interface.Total agreement; if anything it is dead hard to override static method logic with mock code in unit tests (I had to do it by keeping the static methods in place but making them internally use a singleton instance of itself of which the instance variable could be overwritten with a mock implementation for unit testing purposes...).
    'Static classes' and/or methods are great for very simple util functions, but I wouldn't use them for anything other than that.

  • Difference between a static class and singleton

    What is the difference between a static object and a singleton ?
    for example:
    1 )
    public class MyObject {
    static MyObject singleton ;
    public static MyObject getInstance() {
    if (singleton ==null) singleton = new MyObject ();
    return singleton;
    private MyObject () {
    supe();
    public void myMethod() {
    2 )
    public class MyObject {
    private MyObject () {
    supe();
    public static void myMethod() {
    If I need to call the myMethod() , witch of this solution is better ?
    // case 1
    MyObject.getInstance().myMethod()
    // case 2
    MyObject.myMethod()
    .....

    This has been discussed a lot here.
    Use the forum's search feature, or, since it's not necessarily reliable, use google.
    For many intents and purposes, they're equivalent.
    However, with a singleton you can implement an interface, and get polymorphic behavior. You can't do with with a class full of static methods (which, by the way, is NOT a static class).

  • Difference between static class and singleton?

    Hi I wonder what could be the difference between static methods and singleton?
    In singleton at any point of time there will be only one object existing in the JVM. We create singleton to avoid multiple object creation for that class.
    If I make all the methods in the class as static also it does the same job. The memory will be allocated once. Even there wont be any object in this case, so time required for object creation also can be saved. looks like more efficient but still why need singleton?
    This question is also posted in java programming forum. The thread is as follows:-
    [Click on this to visit that thread |http://forum.java.sun.com/thread.jspa?threadID=5278517&tstart=0]
    Edited by: murrayb9654 on Mar 25, 2008 8:20 AM

    yawmark wrote:
    Static class is a realization of singleton pattern.Not in any conventional sense.
    ~Especially since a static class is completely different from a class with all static methods.

  • Alternative to Static Class Inherit

    Greetings,
    I’ve been using some code for years in a different number of applications but that involves a lot of copy paste and is a nightmare to maintain. For that reason I’ve took some time to re-organize some of my codes and that mainly involves
    splitting it into multiple projects for latter inclusion in a number of solutions.
    So far so good and I’d say 95% is done but I’m now stuck with a Static Class I need to use. I basically need a few “Global” parameters and settings to be available across every solution. I know I can’t Inherit a Static Class nor override
    a Field to return a different value unfortunately.
    In a nutshell:
    myFrameworkProject
    namespace
    myFramework.Classes{
                    //these contains general stuff
    used in every project
                    public static class Globals{
                                   public static
    XPTO veryImportantProperty = new XPTO()
                                   public static
    Settings Settings = new Settings();
    public void doSomethingImportant();
    Public class Settings{
                    Private
    string Username;
                    Private
    string Password;
                    Private
    string Whatever;
    myFancyProject
    namespace
    myFancyProject.Classes{
                    //these add specific stuff used
    in this project
                    public static class Globals : myFramework.Classes.
    Globals {
                                   public static
    override mySettings Settings = new mySettings();
    Public class mySettings: myFramework.Classes .Settings{
                    //some
    more specific settings I need
                    Private
    string SomethingElse;
    What are my options? I’ve been trying to play with Singletons but for some reason I just can’t seem to make it work the way I want to…probably because it’s just not the right way to do it in the first place.

    I think you are over thinking it a little bit. The example you have above would be great if you had multiple setting types you wanted to retrieve within the same application domain instance using keys or specific types. The way I understand your problem
    is you have one settings type per application that you run with various applications sharing a code base. Here is an example I created for you which better illustrates the solution I had in mind when I read your problem.
    There are 2 namespaces, the one for your custom project(s) named FancyProject and then the Core / framework. Hope this helps!
    namespace JF.FancyProject
    using JF.Framework.Classes;
    // in initialization of your default application domain (ie. in your application startup)
    // inject your MySingleton with your custom implementation of ISettingsBuilder
    // this can be done in many ways from hard coding in each startup routine to IoC / Dependency Injection
    // the end result is this
    public static class Console
    public static void Main(params string[] args)
    MySingleton.Initialize(new ConcreteSettingsBuilder());
    // now you can use it where ever
    var temp = MySingleton.SettingsConcreteInstance<ConcreteSettings>().SomethingCustom;
    // or base
    var temp1 = MySingleton.SettingsInstance.SomeBaseThing;
    public sealed class ConcreteSettings : JF.Framework.Classes.SettingsBase
    public string SomethingCustom { get; set; }
    public sealed class ConcreteSettingsBuilder : BaseSettingsBuilder, ISettingsBuilder
    public override SettingsBase CreateSettings()
    var settings = new ConcreteSettings();
    // call the base if you need to get standard settings populated
    base.populateBaseSettings(settings);
    // populate all of your custom settings
    return settings;
    namespace JF.Framework.Classes
    public abstract class SettingsBase
    public string SomeBaseThing { get; set; }
    // base settings and behavior that can be abstracted
    public static class MySingleton
    private static SettingsBase _settings;
    private static Lazy<SettingsBase> _lazyCreationMethod;
    public static void Initialize(ISettingsBuilder builder)
    _lazyCreationMethod = new Lazy<SettingsBase>(builder.CreateSettings);
    public static SettingsBase SettingsInstance
    get { return _lazyCreationMethod.Value; }
    public static T SettingsConcreteInstance<T>() where T : SettingsBase
    return (T) _lazyCreationMethod.Value;
    public abstract class BaseSettingsBuilder : ISettingsBuilder
    public abstract SettingsBase CreateSettings();
    protected virtual void populateBaseSettings(SettingsBase settings)
    // if you find many of your settings are created the same way use a base class
    public interface ISettingsBuilder
    SettingsBase CreateSettings();
    Edit:
    One more thought. I do agree with some of the other posters that  for bigger projects the use of a Singleton pattern is not a good idea. For little applications it does not matter too much because chances are there is not enough substance that it will
    hinder your code and the development cycles are generally very short.
    Should you want to reconsider the Singleton pattern then I recommend you look at something like
    Autofac, you could use this to inject instances of your ISettingsBuilder, or other concrete instances, directly into your dependent classes and you could take it further in developing self containing services that you could
    inject as well.
    Again, for small projects its not a big deal but if you ever start on something a bit more complex its worth looking into.
    -Igor

  • Static Class JMS Listener

    I am designing an EJB component (MessageDrivenBean) that requires
    dynamic ("hot") configuration changes. As such, the bean must be
    notified somehow of configuration changes in the DB (rather than have
    to poll the DB for changes at every method call).
    I'm thinking of implementing this functionality using a static class
    instance (singleton) that is shared between the multiple instances of
    the bean. This static instance would listen on a JMS topic for
    configuration change events and update its internal cache accordingly
    (by getting the configuration information from the DB). The beans
    would then access this in-memory static instance everytime they need
    configuration info instead of polling the database. By using the JMS
    topic, I guarantee that clustered instances of Weblogic will all be
    notified of the database changes (each instance would have its own
    "cache" singleton).
    I'm pretty sure all of this will work, but I'm equally sure that I'm
    violating some EJB rules. Singletons and JMS listeners are generally
    discouraged. Are there any alternatives to this design?

    Hi Joost,
    This all seems to be pretty complicated. Not to mention that you can not
    guarantee that members of a cluster will be notified simultaneously.
    Why don't you want using the database?
    "Joost Ouwerkerk" <[email protected]> wrote in message
    news:[email protected]..
    I am designing an EJB component (MessageDrivenBean) that requires
    dynamic ("hot") configuration changes. As such, the bean must be
    notified somehow of configuration changes in the DB (rather than have
    to poll the DB for changes at every method call).
    I'm thinking of implementing this functionality using a static class
    instance (singleton) that is shared between the multiple instances of
    the bean. This static instance would listen on a JMS topic for
    configuration change events and update its internal cache accordingly
    (by getting the configuration information from the DB). The beans
    would then access this in-memory static instance everytime they need
    configuration info instead of polling the database. By using the JMS
    topic, I guarantee that clustered instances of Weblogic will all be
    notified of the database changes (each instance would have its own
    "cache" singleton).
    I'm pretty sure all of this will work, but I'm equally sure that I'm
    violating some EJB rules. Singletons and JMS listeners are generally
    discouraged. Are there any alternatives to this design?Regards,
    Slava Imeshev

  • Singleton vs static - which is better?

    Of the two approaches -
    a class which can be used by accessing its ONLY instance(singleton) or a class which has a set of static methods which can be invoked on the class itself
    which is better and why? Or are these just two 'styles' of programming?
    I always get confused as to which way to go? I tend to prefer to have static methods on the class instead of a singleton.
    All insights/comments/ideas welcome.
    Thanks

    Well, there are a few questions you can ask - does the method cause any changes of state, or is it a pure function? If the latter, static is probably the way to go.
    The way you are talking, I gather that there is some state involved.
    Next question: does it make sense for there to be more than one of these per JVM? Not only in the way you currently envision it, but at all, anywhere. For example, consider the list of Strings that the String class keeps so it can consolidate memory and avoid duplication (see String.intern() ). That list makes sense to be static.
    On the other hand, the representation of the state of a board game should not be static, because someone could want to write a program which has multiple games within it - or you could within one game wish to have contingencies or undo-ability (essentially, it might not be as singleton as you think).
    Next, if you think the methods will ever need to be overridden, use a singleton, because static methods aren't, well, dynamic! (in case the singleton is a one-at-a-time singleton but it makes sense to have a change of identity over time).
    I have never written a true singleton - though often written classes which I did not PLAN on instantiating more than once.

  • Static class garbage collection

    Can garbage collector can garbage collect static classes ?.
    My doubt is that when you access a static class , that class is loaded through its class loader ( when first time that class is referenced ).
    So when did the garbage collector collects this static class ( assume that static class no longer referred ).
    Please do more information,
    What are the ways to prevent garbage collector for a particular class ( Assume that i m implementing a singleton for my java runtime)
    thanks and regards
    Renjith.

    Can garbage collector can garbage collect static classes ?. Static classes are nothing special in terms of class loading - they are only different in visibility for linking.
    Perhaps you mean static members of classes?
    My doubt is that when you access a static class ,
    that class is loaded through its class loader ( when
    first time that class is referenced ). Classes are always loaded through classloaders. Objects of those classes are allocated from the heap, and the object instances refer to the class object.
    Objects (either instances, or classes themselves) are garbage collected when they are no longer live (i.e. no live object refers to them). (This is a somewhat recursive definition, and sometimes, you can have cyclic dependencies that make garbage collection tricky, but the GC, while it has to be conservative for correctness, usually gets it right).
    So for a static member to be garbage-collected, the class has to be garbage-collected first. The class cannot be GC'ed until all references to it go away (this includes all dynamically allocated objects of that type, and the class loader that loaded that class).
    And yes, class loaders can go away, but only if they are created by your program. The system class loader (which is the default classloader you get if you don't create any class loaders of your own) never goes away, so any class loaded from CLASSPATH will never be unloaded.
    (As an example, servlet containers - e.g. Tomcat, Weblogic, etc.) allocate one or more classloaders for each webapp. When the webapp is un-deployed, the classloaders are "orphaned", and they, and any classes loaded by them (from the WEB-INF/lib and WEB-INF/classes directories) are unloaded and garbage-collected. (After all the dynamic objects of those classes are GC'ed, of course).
    >
    So when did the garbage collector collects this
    static class ( assume that static class no longer
    referred ).
    Please do more information,
    What are the ways to prevent garbage collector for a
    particular class ( Assume that i m implementing a
    singleton for my java runtime)
    thanks and regards
    Renjith.

  • Static class

    Hello
    at the start of my programme I would like to store some valuse (the values are trhe user rights that will be read from the data base) these values will never change during the execution of the programme.
    so I was told that the best is to create a static class ...
    can any one post an example of static class and how to store the values inside
    and how to read it back
    or just any link that speak about this
    thank you in advance.

    yeah i understand the ?:;
    my question was on the form of the newthe code checks to see if an instance of Example already exists, and if it does, it returns that. if not, it creates a new one first. theoretically, only one instance will ever exist, but in practice, this variant of the pattern isn't thread-safe. simplest singleton:
    public class MySingleton {
      private static MySingleton INSTANCE = new MySingleton();
      private MySingleton() {}
      public static MySingleton getInstance() {
        return INSTANCE;
    }still lazily-loaded, despite what people might tell you, since the class itself is only loaded when you first need it

  • Static Classes/Methods vs Objects/Instance Classes/Methods?

    Hi,
    I am reading "Official ABAP Programming Guidelines" book. And I saw the rule:
    Rule 5.3: Do Not Use Static Classes
    Preferably use objects instead of static classes. If you don't want to have a multiple instantiation, you can use singletons.
    I needed to create a global class and some methods under that. And there is no any object-oriented design idea exists. Instead of creating a function group/modules, I have decided to create a global class (even is a abstract class) and some static methods.So I directly use these static methods by using zcl_class=>method().
    But the rule above says "Don't use static classes/methods, always use instance methods if even there is no object-oriented design".
    The book listed several reasons, one for example
    1-) Static classes are implicitly loaded first time they are used, and the corresponding static constructor -of available- is executed. They remain in the memory as long as the current internal session exists. Therefore, if you use static classes, you cannot actually control the time of initialization and have no option to release the memory.
    So if I use a static class/method in a subroutine, it will be loaded into memory and it will stay in the memory till I close the program.
    But if I use instance class/method, I can CREATE OBJECT lo_object TYPE REF TO zcl_class then use method lo_object->method(), then I can FREE  lo_object to delete from the memory. Is my understanding correct?
    Any idea? What do you prefer Static Class OR Object/Instance Class?
    Thanks in advance.
    Tuncay

    @Naimesh Patel
    So you recommend to use instance class/methods even though method logic is just self-executable. Right?
    <h3>Example:</h3>
    <h4>Instance option</h4>
    CLASS zcl_class DEFINITION.
      METHODS add_1 IMPORTING i_input type i EXPORTING e_output type i.
      METHODS subtract_1 IMPORTING i_input type i EXPORTING e_output type i.
    ENDCLASS
    CLASS zcl_class IMPLEMENTATION.
      METHOD add_1.
        e_output = i_input + 1.
      ENDMETHOD.
      METHOD subtract_1.
        e_output = i_input - 1.
      ENDMETHOD.
    ENDCLASS
    CREATE OBJECT lo_object.
    lo_object->add_1(
      exporting i_input = 1
      importing e_output = lv_output ).
    lo_object->subtract_1(
      exporting i_input = 2
      importing e_output = lv_output2 ).
    <h4>Static option</h4>
    CLASS zcl_class DEFINITION.
      CLASS-METHODS add_1 IMPORTING i_input type i EXPORTING e_output type i.
      CLASS-METHODS subtract_1 IMPORTING i_input type i EXPORTING e_output type i.
    ENDCLASS
    CLASS zcl_class IMPLEMENTATION.
      METHOD add_1.
        e_output = i_input + 1.
      ENDMETHOD.
      METHOD subtract_1.
        e_output = i_input - 1.
      ENDMETHOD.
    ENDCLASS
    CREATE OBJECT lo_object.
    lo_object->add_1(
    zcl_class=>add_1(
      exporting i_input = 1
      importing e_output = lv_output ).
    lo_object->subtract_1(
    zcl_class=>subtract_1(
      exporting i_input = 2
      importing e_output = lv_output2 ).
    So which option is best? Pros and Cons?

  • Static class error

    I have a static class:
    package VO
        public class ArrayValues
            private static var instance:ArrayValues = new ArrayValues();
            // dummy values will be first replaced with English versions
            // if the user clicks "Spanish" they will be replaced with that
            private var yesNoArray:Array = new Array('1','2');
            private var utilityArray:Array = new Array('1','2');
            public function ArrayValues()
                throw Error("ArrayValues is called by its instance");
            public static function getInstance():ArrayValues
                return instance;
            public function getYesNoArray():Array
                return yesNoArray;
            public function setYesNoArray(input:Array):void
                yesNoArray = input;
    It is invoked here:
            import VO.ArrayValues;
            import VO.InputData;
            import VO.InputLabels;
            [Bindable]
            public var saveData:InputData = InputData.getInstance();
            [Bindable]
    168       public var getArrays:ArrayValues = ArrayValues.getInstance();
    It produces this error:
    Error: ArrayValues is called by its instance
        at VO::ArrayValues()[C:\FSCalc\Flex\FSCalc\src\VO\ArrayValues.as:14]
        at VO::ArrayValues$cinit()
        at global$init()[C:\FSCalc\Flex\FSCalc\src\VO\ArrayValues.as:3]
        at components::InputForm()[C:\FSCalc\Flex\FSCalc\src\components\InputForm.mxml:168]
        at FSCalc/_FSCalc_InputForm1_i()
        at FSCalc/_FSCalc_Array6_c()
    What am I doing wrong?
    PS, is it normal to take almost 10 minutes to a) go to your discussions, b) read one response to one thread and c) get back to the normal discussion?  That seems excessive to me.

    Sorry for the late reply.  I've just got back to this project after the usual "an emergency" stuff.
    Yes, I'm looking to create a singleton.  I want to pass values around without having to have monster long parameter lists for the various components.
    I based the Flex I have on a web page and noted it is similar to the java idea, but not identical based on that page.
    I want to make sure I understand the theory behind the code.
    public function ArrayValues(access:SingletonEnforcer)
         if ( access == null )
              throw Error("ArrayValues is called by its instance");
    This is the constructor for the class which has the same name as the file it is in.  A parameter is passed of the type "SingletonEnforcer" and is then tested to see if it were ever invoked.  If it were, an error is created with a string which will be written to the console.
    Next, a variable local to this class is created that will be of the type "ArrayValues" to hold the various arrays.  BTW, either this will have to be expanded or a parallel class created to hold the Spanish values.
    static private var _instance  :  ArrayValues;
    Next, the actual work horse and true "constructor" is made.  This will either allocate a new instance of the class if it doesn't already exist or instantiate it if it doesn't.  I am confused by the second class, however, when it is created the first time.  This class is included in this file?  Doesn't the file name have to match the class?

Maybe you are looking for

  • Web Service Task in SSIS 2012

    Hello, I have a web service task that worked fine prior to upgrading from SQL Server 2005, but in 2012 fails with an error saying the "wsdl file is invalid".  I am using the same wsdl file as I was using in 2005.  Connectivity tests for the web servi

  • VIEW won't display channels with same names

    Hello, We have recently installed DIAdem 2010 and are beginning to find channel name problems that we didn't have before with 9.1. Traditionally we have always set the name-oriented channel references to 'only channel name' and we have never had any

  • Loading an external swf music player

    Hello, my problem is that all the action script contained in the musicplayer.swf seems not to work when I load the whole musicplayer.swf in the main movie.what can I do to resolve this? here is the code:

  • Not able to print with an P1102 through a buffalo link station LS-QVL

    Hi, I've seen older posts on this subject which have not resolved my issue.  The printer is visible and the PC (win 7 32 bit) sends the document to the printer, the doc disapears from the que, but never re-appears out of the printer.  Full setup for

  • Need help from experts with process of printing Payroll Checks in-House

    Appreciate any information on below issues please. We upgraded from 4.0 to 4.7 1. For some reason 10 Direct Deposit advises get destroyed and need to be reprint only those 10, instead of whole 2000 2. Is there a way to change payment method (T-C with