关于java中枚举接口的问题 [英] Issue on Enumeration Interface in java

查看:70
本文介绍了关于java中枚举接口的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里我知道Enumeration是一个interface.is接口,能够在其中保存数据。这个代码我来自Javatutorialpoint site.please clarifymu怀疑。





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

public class EnumerationTester {

public static void main( String args []){
枚举天数;
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());
}
}
}

解决方案

不,你知道它错了。接口不是保存数据的东西。接口是接口。并且没有疑问需要澄清。如果你解释了一些疑问会很好,但你只是展示代码样本,甚至不是你写的。这不是一个问题,也不是获取知识的有效方式。



你看过的样本来自这里:http://www.tutorialspoint.com/java/java_enumeration_interface.htm [ ^ ]。



(这太糟糕了,你没有提供链接你认为成员没有比用你的代码片段搜索文章更有用了吗?请始终引用你所引用的所有内容。毕竟,不这样做会侵犯原始内容作者的基本权利。)



此代码示例中使用的接口是: http://docs.oracle.com/javase/7/docs/api/java/util/Enumeration.html [ ^ ]。



一切都清楚地解释了。这个接口的目的是提供支持迭代的构造, for 循环。



首先,重要的是不要将此特定接口与枚举类型混淆: https://docs.oracle。 com / javase / tutorial / java / javaOO / enum.html [ ^ ]。



最有可能的是,唯一可以帮助你的是语言和技术的系统研究,从基本面开始。你需要很好地学习什么是类型和实例,变量和对象,什么是接口,接口如何工作,以及更多。



-SA

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


这篇关于关于java中枚举接口的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆