create and an enumeration of elements by instanting

Hi,
is possible to instantiate java.util.Enumeration with some elements at once?
komlaaaAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
you just instantiate a Collection (eg. Vector) with your elements and get the Enumeration from the Collection.
0
 
CEHJCommented:
You can't instantiate any kind of Enumeration - it's an interface
0
 
hoomanvCommented:
you must subclass it in order to do instantiating.

class YourEnumeration<E> implements java.util.Enumeration<E> {
      public boolean hasMoreElements() {
            // implement
      }

      public E nextElement() {
            // implement
      }
}
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Mayank SAssociate Director - Product EngineeringCommented:
What do you intend to do after instantiating an enumeration? An enumeration is not independent but is dependent over something (like a collection, over which it enumerates).

http://www.cs.wisc.edu/~solomon/cs537/java-tutorial.html
0
 
komlaaaAuthor Commented:
Thanks object, I am sure you mean something like:
Enumeration e = v.elements() ;
         
Mayankeagle:
>> What do you intend to do after instantiating an enumeration?
Well i had a method that takes an Enumeration as argument, that is after instantiating the enumeration, i will pass it to
the method i am not supposed to change.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> that is after instantiating the enumeration,

You will not instantiate it. You will get it from something (like a collection) and then pass it to the method.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.