aspose file tools*
The moose likes Beginning Java and the fly likes Enumeration interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Enumeration interface" Watch "Enumeration interface" New topic
Author

Enumeration interface

Vijay pillai
Ranch Hand

Joined: Jan 10, 2001
Posts: 45
hello
I would like to know about the interface Enumeration.
since Interfaces has methods which are abstract(not defined).
how is it that we find this code running.
Enumeration e=//+a code that returns Enumeration object.
while(e.hasMoreElements())
{
e.nextElement();
}
my doubt is .how could we call the undefined methods of the Enumeration interface without declaring it in any way.
e.hasMoreElements();
e.nextElement();
pls help.
vijay
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
This is the whole point of interfaces. By using the interface Enumeration, you are indicating that you don't care which actual class the object returned is an instance of, only that it implements Enumeration.
Consider the following code sample:


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Enumeration interface