Hello Folks, Can i copy the contents of one enumeration into another enumeration.Please help me out. Thanks in Advance. Ravi
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
An Enumeration is an (old) interface. Nothing in that interfacce allows you to store new elements in that enumeration. You could of course catenate two (or more) enumerations as follows:
kind regards
Ravi Kumar Ravuru
Ranch Hand
Joined: Apr 18, 2002
Posts: 176
posted
0
Hello Jos Horsmeier, Thanks for ur reply.But i need to copy the elements of one enumeration to another enumeration. Is it possible. Ravi
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
No, it's not possible, like I wrote in my previous reply: an enumeration is simply an interface, nobody knows whether or not the implementing class is able to 'store' additional objects in it. All you can do is iterate over the two enumerations and store the retrieved objects in, say, an ArrayList or Vector or similar. For the sake of the argument, assume that the 'other' enumeration, where you want to store additional values, is implemented as:
This silly class makes up a perfectly valid Enumeration, but you sure cannot store any elements in it ... kind regards
What you can do is to copy each element of the original enumeration to a Vector, and then get an enumeration of the vectored elements via the elements() method. hth, bear