Click here to Skip to main content
15,891,935 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Here i know that Enumeration is a interface.is interface has the ability of hold data within it.This code i have got from Javatutorialpoint site.please clarifymu doubt.


Java
import java.util.Vector;
import java.util.Enumeration;

public class EnumerationTester {

   public static void main(String args[]) {
      Enumeration days;
      Vector dayNames = new Vector();
      dayNames.add("Sunday");
      dayNames.add("Monday");
      dayNames.add("Tuesday");
      dayNames.add("Wednesday");
      dayNames.add("Thursday");
      dayNames.add("Friday");
      dayNames.add("Saturday");
      days = dayNames.elements();
      while (days.hasMoreElements()){
         System.out.println(days.nextElement()); 
      }
   }
}
Posted
Updated 15-Nov-15 19:16pm
v2
Comments
Patrice T 16-Nov-15 1:16am    
Not a question.
Improve the question until one can understand it without the knowledge of details you didn't tell us.

1 solution

No, you "know" it wrong. Interface is not something that holds data. Interface is interface. And there is no "doubt" to clarify. It would be good if you explained some doubt, but you just show the code sample, not even written by you. This is not a question, and not a productive way of getting knowledge.

The sample you've looked at is from here: http://www.tutorialspoint.com/java/java_enumeration_interface.htm[^].

(It's too bad you did not provide the link. Do you think that members have nothing more useful to do than searching articles by your code fragments? Please always reference all you quote. After all, failure to do that violates basic rights of the authors of the original content.)

The interface uses in this code sample is this: http://docs.oracle.com/javase/7/docs/api/java/util/Enumeration.html[^].

Everything is explained quite clearly. The purpose of this interface is to provide the construct supporting iteration, "for" loops.

First of all, it's important not to mix up this particular interface with enumeration types: https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html[^].

Most likely, the only thing which can help you would be systematic study of the language and technology, starting from the fundamentals. You need to learn very well what are types and instances, variables and objects, what is interface, how interfaces work, and a lot more.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900