本月博客排行
-
第1名
duanfei -
第2名
benladeng5225 -
第3名
steven789654 - wddpwzzhao123
年度博客排行
-
第1名
龙儿筝 -
第2名
宏天软件 -
第3名
wy_19921005 - benladeng5225
- kaizi1992
- tanling8334
- vipbooks
- sam123456gz
- arpenker
- zysnba
- fantaxy025025
- wallimn
- e_e
- jh108020
- ganxueyun
- Xeden
- xyuma
- wangchen.ily
- zhanjia
- johnsmith9th
- zxq_2017
- forestqqqq
- jbosscn
- daizj
- xiangjie88
- xpenxpen
- 喧嚣求静
- lchb139128
- kristy_yy
- javashop
- lzyfn123
- sunj
- yeluowuhen
- ajinn
- lerf
- lemonhandsome
- chenqisdfx
- xiaoxinye
- flashsing123
- lyndon.lin
- bosschen
- zhangjijun
- sunnylocus
- lyj86
- paulwong
- sgqt
- 青否云后端云
- hudiemeng870329
- mft8899
- java_doom
最新文章列表
LeetCode - Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
Calling next() will return the next smallest number in the BST.
Note: next() ...
Iterator和Enumeration 区别 fail-fast 机制
“Iterator(迭代器)” 或 “Enumeration(枚举类)” 都可以遍历集合,Iterator和Enumeration都是接口,主要区别在于接口数、fail-fast机制:
(01) 函数接口不同:Enumeration只有2个函数接口。通过Enumeration,我们只能读取集合的数据,而不能对数据进行修改。Iterator只有3个函数接口。Iterator除了能读取集合的数 ...
集合框架里Iterator迭代器内部实现原理:使用内部类
/*
* 集合框架里Iterator内部实现原理:使用内部类
interface Collection
{
}
interface Iterator
{
public boolean hasNex ...
Iterator,for,forEach的遍历和效率
对应数据的遍历方式有很多,下面介绍下Iterator,for,forEach三种方式的遍历和执行效率问题
1.代码如下:
/**
* Iterator,for,forEach比较
* @author w2cboy
* date 2014-03-24
*/
public class Test {
private static final int COUNT ...
DesignPattern : Iterator
1. A simple mockup for ArrayList
package edu.xmu.designPattern.DesignPattern_Iterator;
public class ArrayList
{
private Object[] objects = new Object[10];
private int index = 0;
public v ...
ResultSet某一列的结果集
一 通过PreparedStatement得到ResultSet之后,怎么得到莫一列的特定值?
ResultSet rs = pst.executeQuery(); List list = new ArrayList(); while (rs.next()){ list.add(rs.getString(&quo ...
iterator与iterable
用Iterator模式实现遍历集合
Iterator模式是用于遍历集合类的标准访问方法。它可以把访问逻辑从不同类型的集合类中抽象出来,从而避免向客户端暴露集合的内部结构。
例如,如果没有使用Iterator,遍历一个数组的方法是使用索引:
for(int i=0; i<array.size(); i++) { ... get(i) ... }
而访问一个链表(LinkedList)又必须使用 ...
10、java.util.Collection集合类
一、为什么出现集合类?
面向对象语言对事物的体现都是以对象的形式,所以为了方便对多个对象的操作,就对对象进行存储,集合就是存储对象最常用的一种方式
二、数组和集合类同是容器,有何不同?
数组虽然可以存储对象,但长度是固定的
集合长度是可变的
数组中可以存储基本数据类型和对象
集合只能存储对象
三、集合类的特点
集合只用于存储对象,长度是 ...
Map的遍历
//countMap已存在的Map集合
Iterator it=countMap.entrySet().iterator();
while(it.hasNext()){
Map.Entry<String, Integer> tempMap=(Entry<String, Integer>) it.next();
//获取键和值
System.out.printl ...