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 ...
随机推荐
- ICEM二维网格
非结构网格 结构网格 拓扑 拓扑完建立part边界条件,然后创建block 拓扑完后进行边界条件关联 全局网格设置
- 康奈尔大学CFD课程
先上链接:https://confluence.cornell.edu/display/SIMULATION/Home 如果不会FQ,可以去edx:https://courses.edx.org/co ...
- scrapy框架的另一种分页处理以及mongodb的持久化储存以及from_crawler类方法的使用
一.scrapy框架处理 1.分页处理 以爬取亚马逊为例 爬虫文件.py # -*- coding: utf-8 -*- import scrapy from Amazon.items import ...
- c#项目后期生成事件命令行常用命令
1. xcopy (复制文件) xcopy参数介绍 命令格式:XCOPY source [destination] 一堆可选的参数 参数介绍 source 指定要复制的文件. destinatio ...
- windows同时安装python2和python3两个版本
1.安装python2 下载地址: https://www.python.org/downloads/windows/ 进入页面,下拉,64位系统要选择这个. 下载完成后,一直点击下一步,直到安装完毕 ...
- element-ui多选框reserve-selection指定row-key保留数据更新之前的数据
element-UI 的table表格数据有提供多项框的功能,只要在表格列中多加一列就可以选择表格的数据 但是有时候表格的数据是有分页的,分页一般是要重新请求后台数据,这样上一页也就是上一次请求的数据 ...
- # 防止xss攻击,过滤script标签,获取出标签外的内容
from bs4 import BeautifulSoups = '<h1>123</h1> <span>456<span>'soup = Beauti ...
- select 点击的时候获取 value值
<select onchange="selectUrl1(this.options[this.options.selectedIndex].value);"> ...
- CentOS初试
由于实在是对ubuntu不太感冒,加上买的鸟哥又是拿CentOS做的例子,所以我就把ubuntu换成了CentOS6.5.依旧win7,CentOS 双系统,具体过程参照http://www.cnbl ...
- jQuery 菜单小练习(实现点击和移动鼠标效果)
这个代码的练习是点击事件后 如何用jQuery联动的方式找到相关标签 实现的结果是点击菜单一或者菜单二等 会出现相关菜品,并隐藏其他菜品.鼠标移动才菜品上会在右侧框内出现相关菜品的价格.实现特殊的效果 ...