Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enumeration interface

 
Vijay pillai
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic