java接口枚举传输,关于java中枚举接口的问题

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.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());

}

}

}

解决方案

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值