Enumeration 接口的使用
publicinterfaceEnumeration<E>{boolean hasMoreElements();E nextElement();}
package com.wang.interfaceTest;import java.util.Enumeration;/*** 此类用于测试枚举接口* @author Administrator**/publicclassEnumerationTestimplementsEnumeration<String>{privateint count;privateint length;privateString[] arr;publicEnumerationTest(int count,int length,String[] arr){this.count = count;this.length = length;this.arr = arr;}@Overridepublicboolean hasMoreElements(){return(count<length);}@OverridepublicString nextElement(){returnthis.arr[this.count++];}publicstaticvoid main(String[] args){String[] myArr =newString[]{"哈哈","呵呵","嘿嘿","嘎嘎","哇哇","咩咩"};EnumerationTest et =newEnumerationTest(0, myArr.length, myArr);while(et.hasMoreElements()){System.out.println(et.nextElement());}}}
哈哈呵呵嘿嘿嘎嘎哇哇咩咩
Enumeration 接口的使用的更多相关文章
- Java Enumeration接口
Enumeration接口定义 Enumeration接口与Iterator接口用法比较 一. 1.Enumeration接口定义 public interface Enumeration<E& ...
- Vector类与Enumeration接口
Vector类用于保存一组对象,由于java不支持动态数组,Vector可以用于实现跟动态数组差不多的功能.如果要将一组对象存放在某种数据结构中,但是不能确定对象的个数时,Vector是一个不错的选择 ...
- 20180824-Java Enumeration 接口
Java Enumeration接口 Enumeration接口中定义了一些方法,通过这些方法可以枚举(一次获得一个)对象集合中的元素. 这种传统接口已被迭代器取代,虽然Enumeration 还未被 ...
- Java中Enumeration接口的用法
Enumeration是java.util中的一个接口类,在Enumeration中封装了有关枚举数据集合的方法,与Iterator差不多,用来遍历集合中的元素 但是枚举Enumeration只提供 ...
- 【Java基础】9、Enumeration接口和Iterator接口的区别
package java.util; public interface Enumeration<E> { boolean hasMoreElements(); E next ...
- Enumeration接口和Iterator接口的区别有哪些?
Enumeration速度是Iterator的2倍,同时占用更少的内存.但是,Iterator远远比Enumeration安全,因为其他线程不能够修改正在被iterator遍历的集合里面的对象.同时, ...
- Enumeration 接口
Enumeration是遍历集合元素的一种方法. Enumeration中只有两个方法: 1.hasMoreElements() 测试此枚举是否包含更多的元素. 2.nextElement() 如 ...
- 枚举 Java Enumeration接口
Enumation 定义了一些方法,通过这些方法可以枚举对象集合中的元素 如: boolean hasMoreElements() 测试此枚举是否包含更多的元素 object nextElement( ...
- 吴裕雄--天生自然java开发常用类库学习笔记:foreach及Enumeration接口
import java.util.Vector; import java.util.Enumeration; public class EnumerationDemo01{ public static ...
随机推荐
- prcharm 注册码
JetBrains全系列在线激活中心 使用方法: 1. 点击Help,选择Register.打开注册页面. 2. 选择License server, 在License server address 中 ...
- selenium python 时间控件的输入问题
对于时间的选择问题,查到的大部分为两种情况: 1.存在readonly属性的 2.没有readonly属性的 可直接赋值send_keys() 测试用例中刚好是没有readonly属性的 且定位不到弹 ...
- LeetCode109. 有序链表转换二叉搜索树
109. 有序链表转换二叉搜索树 问题描述 给定一个单链表,其中的元素按升序排序,将其转换为高度平衡的二叉搜索树. 本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超 ...
- java的长字符串转化为短字符串
public class CustomEncrypt{ public static void main( String[] args ) { /* * c#给的正确测试用例: id=>mid * ...
- hdu 2654 Be a hero
()Become A Hero Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 超文本传送协议 HTTP
超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所有的WWW文件都必须遵守这个标准. HTTP是一个属于应用层的面向对象的协议, ...
- 墨菲定律&吉德林法则&吉尔伯特定律&沃尔森法则&福克兰定律
一.墨菲定律:越害怕什么,就越会发生什么 二.吉德林法则:把问题清楚地写下来,就已经解决一半了 三.吉尔伯特定律:工作中的最大问题就是没人跟你说该如何去做 四.沃尔森法则:把信息和情报排在第一位,金钱 ...
- 01-oracle限定查询-20190404
关系型数据库和半结构化数据(xml文件) oracle12c:c代表云计算 PDB,CDB sql语句执行顺序: 第一步:from子句控制数据来源: 第二步:where子句使用限定符对数据行过滤: 第 ...
- vsftpd配置文件解析
对vsftpd配置文件详细解答. 1.默认配置: 1>允许匿名用户和本地用户登陆. anonymous_enable=YES local_enable=YES 2>匿名用户使用的登陆名为f ...
- Composite Design Pattern in Java--转
https://dzone.com/articles/composite-design-pattern-in-java-1 The composite pattern is meant to &quo ...