?
Solved

create and an enumeration of elements by instanting

Posted on 2006-05-09
6
Medium Priority
?
223 Views
Last Modified: 2010-03-31
Hi,
is possible to instantiate java.util.Enumeration with some elements at once?
0
Comment
Question by:komlaaa
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16640599
You can't instantiate any kind of Enumeration - it's an interface
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 16640836
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
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 16643674
you just instantiate a Collection (eg. Vector) with your elements and get the Enumeration from the Collection.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 30

Expert Comment

by:Mayank S
ID: 16645225
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
 

Author Comment

by:komlaaa
ID: 16654486
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 16655030
>> 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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question