This discussion is archived
3 Replies Latest reply: Dec 28, 2007 9:52 AM by 807603 RSS

Creating a dynamic ENUM object?

800467 Newbie
Currently Being Moderated
Hi all,

I have the requirement to add a new XYZ object to a list of XYZ - as in: List<XYZ> xyz = new ArrayList<XYZ>();

Within the XYZ enum I currently have the following object that can be created e.g.:
FirstObject()
    {
        public String displayString()
        {
            return "Some text";
        }
    }
So what I want to do is something like (by definining a constructor for the enum which takes in a String as an argument:
SecondObject()
    {
        public String displayString(userString)
        {
            return userString;
        }
    }

xyz.add(Function.NEW_ENUM("userVar"));
I need to be able to create a new ENUM on the fly (called NEW_ENUM) which takes in a the String, and add that to the ENUM list - is this possible or does this defeat the whole point of using the ENUM as a constant? Which I suspect it does.



Thanks for any info...