第46条 for-each循环优先于传统的for循环

《effective java》 第46条:for-each循环优先于传统的for循环 enum NUMS {ONE, TWO, THREE, FOUR, FIVE, SIX} enum NUMS2 {ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN} public static void main(String[] args) { Collection<NUMS&... 阅读详情

迭代器循环的缺点

如下面代码及输出结果所示,本来期望输出的是Face枚举值的笛卡尔积、36种结果,实际上输出只有6种结果。原因就是i和j本质上都是同一个引用对象,所以遍历过程中、两者是同时变化的。

enum Face {ONE, TWO, THREE, FOUR, FIVE, SIX}
Collection<Face> faces = Arrays.asList(Face.values());
for (Iterator<Face> i = faces.iterator(); i.hasNext();) {
	for (Iterator<Face> j = faces.iterator(); j.hasNext();) {
    	System.out.println(i.next() + " " + j.next());
	}
}

输出结果

使用for-each循环

for (Face face : faces) {
   	for (Face face1 : faces) {
    	System.out.println(face + " " + face1);
	}
}

优点:完全隐藏迭代器或索引变量,避免了混乱和出错的可能,代码简洁性高、bug率低。这种模式同样适用于集合和数组。
同样地,任何实现了Iterable接口的对象,通可以通过for-each循环遍历。

不能使用for-each循环的三种场景

  • 过滤:若需要遍历集合并删除其中的某个元素,则应该使用显示的迭代器
  • 转换:若需要遍历列表或数组,并取代部它部分或全部的元素值,就需要列表迭代器或者数组索引,以便设定元素的值。
  • 平行迭代:如果需要并行地遍历多个集合,就需要显示地控制迭代器或者索引变量,以便所有迭代器或者索引变量都可以得到同步前移。
enum Number {1, 2, 3, 4, 5, 6}
List<Number> numbers = Arrays.asList(Number.values());
for(int i = 0; i < 6; i ++) {
	System.out.println(faces.get(i) + " - " + numbers.get(i));
}

for循环内部禁止remove操作

如上述不能使用for-each循环的三种场景的第一种场景,其实就是禁止在for循环内部使用remove操作。

 List<String> list = new ArrayList<String>();
 list.add("1");
 for (String item : list) {
	if ("1".equals(item)) {
		list.remove(item);
    }
} 
System.out.println(list.toString());
// 抛出异常 
Exception in thread "main" java.util.ConcurrentModificationException
	at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:907)
	at java.util.ArrayList$Itr.next(ArrayList.java:857)
	at com.zhc.generic.TestForeach.main(TestForeach.java:27)
     

而使用迭代器遍历的时候,使用remove操作是正常的

List<String> list = new ArrayList<String>();
list.add("1");
Iterator<String> iterator = list.iterator();
while(iterator.hasNext()){
	String item = iterator.next();
    if("1".equals(item)){
    	iterator.remove();
     }
}
System.out.println(list.toString());
// 输出空数组[]

那么这是为什么呢?
我们看上面的异常是从java.util.ArrayList$Itr.checkForComodification方法内抛出的,所以我们来看看源码。

public abstract class AbstractList<E> extends AbstractCollection<E> implements List<E> {
	protected transient int modCount = 0; // 集合被修改次数
}

private class Itr implements Iterator<E> {
	int cursor;       // index of next element to return
    int lastRet = -1; // index of last element returned; -1 if no such
    int expectedModCount = modCount;
	final void checkForComodification() {
    	if (modCount != expectedModCount)
        	throw new ConcurrentModificationException();
  	}
 }

其实,就是预期的集合被修改次数expectedModCount与实际的被修改次数modCount不相等,那么我们再来看看这两个参数都会在哪里被修改。其中迭代器中的remove方法会调用ArrayList的remove(int index)方法,该方法内会看到会修改modCount,然后会将被修改过的modCount赋值给expectedModCount,这样就能保证两者始终是同步被修改的、最终的值也是相等的,因此在遍历集合过程中删除依然能正常运行。

private class Itr implements Iterator<E> {
	public void remove() {
		if (lastRet < 0)
	    	throw new IllegalStateException();
	    	checkForComodification();
		try {
	    	ArrayList.this.remove(lastRet);
	        cursor = lastRet;
	        lastRet = -1;
	        expectedModCount = modCount;
	     } catch (IndexOutOfBoundsException ex) {
	     	throw new ConcurrentModificationException();
	     }
	}
}

public E remove(int index) {
	rangeCheck(index);
	modCount++;
    E oldValue = elementData(index);
    int numMoved = size - index - 1;
    if (numMoved > 0)
   		System.arraycopy(elementData, index+1, elementData, index,numMoved);
		elementData[--size] = null; // clear to let GC do its work
	return oldValue;
    }

我们继续看ArrayList的remove(Object o)方法,该方法内部调用的fastRemove方法内部同样会修改modCount,但是与迭代器的remove方法的最明显的差别就是没有修改expectedModCount的值。因此,如果在foreach遍历集合过程中执行remove操作,就会抛出运行时异常ConcurrentModificationException。

public boolean remove(Object o) {
	if (o == null) {
   		for (int index = 0; index < size; index++)
       		if (elementData[index] == null) {
            	fastRemove(index);
                return true;
            }
	} else {
    	for (int index = 0; index < size; index++)
        	if (o.equals(elementData[index])) {
            	fastRemove(index);
                return true;
           	}
    }
	return false;
}

private void fastRemove(int index) {
	modCount++;
    int numMoved = size - index - 1;
    if (numMoved > 0)
    	System.arraycopy(elementData, index+1, elementData, index,numMoved);
	elementData[--size] = null; // clear to let GC do its work
}
JDK1.5中增强for循环 JDK1.5新特性中的最重要的一点。让你彻底明白增强for循环的强大和方便 立即下载

相关推荐

【AUTOSAR-COM】Transmission Mode 和 Transfer Property

1.COM模块的基本概念 首先在描述Transmission Mode 和 Transfer Property之前,有必要对COM模块的基本处理有一个直观的理解,我所描述的和对概念理解的也不一定完全正确。 Signal:指的是通信协议中的,一条报文中所保存的若干信号。 I-PDU:至少在COM模块中,可以理解为一条报文。 上图是在CANdb软件中编辑一个报文的Layout的界面,可以很形象的将I-PDU对等为这里的一条Message,而Signal就是需要在Message中需要摆放的Signal

tim_hoven的博客 4644

python:永远别写for循环

在网上看到一篇关于python避免写for循环的博文,mark一下,值得思考! 为什么要挑战自己在代码里不写for loop?因为这样可以迫使你去使用比较高级、地道的语法或库。文中以python为例子,讲了不少大家其实在别人的代码里都见过、但自己很少用的语法。 这是一个挑战。我要你避免在任何情况下写for循环。同样的,我也要你找到一种场景——除了用for循环以外,用其他方法

wonengguwozai的博客 4万+

用Python实现四叉树(quad tree)

import numpy as np #正方形类 class square: #lx、ly为左上角坐标(x对应行号,y对应列号),rx、ry为右下角坐标 def __init__(self,lx,ly,rx,ry): self.lx=lx self.ly=ly self.rx=rx self.ry=ry #检查该矩阵中是否满足条件 #参数:原矩阵,阈值 #返回值:布尔类型 def check(s

weixin_44164489的博客 5869

Java 8 习惯用语,第 3 部分 传统 for 循环的函数式替代方案

原文地址:https://www.ibm.com/developerworks/cn/java/j-java8idioms3/index.html Java 8 习惯用语,第 3 部分 传统 for 循环的函数式替代方案 3 个消除复杂迭代中的麻烦的新方法 Venkat Subramaniam 2017 年 6 月 05 日发布

挖坑小队长 3223

从实验室到生活:构建一份全面的手机相机主观画质评测指南

本文详细介绍了如何从实验室数据转向实际体验,构建全面的手机相机主观画质评测指南。通过基础装备清单、室内外场景实战评测及数据之外的感知艺术,帮助用户发现手机相机在色彩还原、动态范围和夜景模式等方面的真实表现。特别关注主观体验与客观参数的差异,提供实用的评测技巧和报告撰写心法。

weixin_30940783的博客 309

未来计算的革命:探索存算一体芯片的潜力与挑战

未来计算的革命:探索存算一体芯片的潜力与挑战

jtwqwq的博客 1621

for-each循环优先于传统的for循环

for-each循环优先于传统的for循环

wcg_jishuo的专栏 434

DISK配置服务器软RAID工作任务(RAID1+BITLOCKER)-winserver4

DISK配置服务器软RAID工作任务(RAID1+BITLOCKER)-winserver4

新时代先锋的博客 7301

Java 8 新语法习惯 (for 循环的函数替代方案)

我们最常用的迭代一个数据集的方式就是 for 循环,开发人员对它可谓是非常的熟悉。从 Java 8 开始,我们有多个强大的新方法可以帮助我们简化复杂的迭代。在本文中,您将了解如何使用 InStream 方法、range、iterate 和 limit 来迭代范围和跳过范围中的值。还将了解新的 takeWhile 和 dropWhile 方法。 for 循环的麻烦 在 Java 语言的第一个版本中就...

weixin_34221773的博客 1559

基于Blender软件对Matterport3D数据集场景可视化

使用Blender软件对 Matterport3D 中的室内场景进行可视化。

qq_44100524的博客 291

YOLOv10精度上不去?QAT量化感知训练全流程,INT8推理mAP只掉0.8%

普通PTQ量化虽简单,但无法应对YOLOv10的小目标特征和激活分布波动,导致精度暴跌。QAT通过“模拟量化误差+联合优化权重与量化参数”,让INT8模型精度接近FP16,同时速度提升1.8倍,完美适配实时检测场景(如安防监控、自动驾驶)。该流程已在工业级项目中验证,针对YOLOv10的优化策略(敏感层保护、小目标加权、分阶段训练)可直接迁移至其他YOLO系列(v8/v9),量化后精度损失均可控制在1%以内。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 918

跟我学(Effective Java 2)第46条:for-each循环优先于传统的for循环

第46条:for-each循环优先于传统的for循环 for-each循环通过完全隐藏迭代器或者索引变量,避免混乱和出错的可能,适用于集合和数组和任何实现Iterable接口的对象。 enum Suit { CLUB, DIAMOND, HEART, SPADE } enum Rank { ACE, DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE...

Dullon_jiang的博客 292

记录:解决Ubuntu20.04安装ros报错E: Unable to locate package ros-kinetic-desktop-full【亲测有效】

报错:E: Unable to locate package ros-kinetic-desktop-full.尝试好久一直都无法下载,最后得知真相的我眼泪哗哗的直流。

**My Coding Family** 6万+

长按开关机芯片选型指南:5个参数决定续航与量产成败

在电池供电的便携设备中,电源管理的第一道闸门往往由长按开关机芯片(又称按键控制器、Push Button Controller)承担。它通过检测按键时长驱动内部状态机,控制外部MOS或集成功率管通断负载,其静态电流与关机漏电直接决定整机待机寿命。若只关注标称电压而忽略UVLO、RDS(on)、保持窗口等参数,轻则续航骤降,重则量产返工。TWS充电仓、蓝牙音箱、手持小风扇等场景都依赖这类器件实现低功耗开关。围绕长按开关机芯片选型,拆解输入电压范围、静态电流、长按判定、通路能力、控制接口与保护五个关键参数,并给

weixin_33795806的博客 240

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

第46条:for-each循环优先于传统的for循环

为什么80%的码农都做不了架构师?>>> ...

weixin_34402408的博客 87

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Effective Java - 第46条:for-each循环优先于传统的for循环

effective java

数据挖掘|数据开发|数据分析开发|大数据|hbase|hadoop|云存储|云计算|推荐系统 808

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Effective Java 学习笔记(第46条:for-each循环优先于传统的for循环)

for(Element e : elements) { doSomething(e);} for-each循环在简洁性和预防BUG方面有着传统的for循环无法比拟的优势,并且没有性能损失。应该尽可能地使用for-each循环。遗憾的是,有三种常见的情况无法使用for-each循环:1.过滤——如果需要遍历集合,并删除选定的元素,就需要使用显式的迭代器,以...

weixin_34341229的博客 131

Effective Java(2nd Edition) Item 46 for-each循环优于传统的for循环(译文)

版本1.5之前,在集合上迭代优先考虑的习惯用法如下:// No longer the preferred idiom to iterate over a collection!for (Iterator i = c.iterator(); i.hasNext(); ) {       doSomething((Element) i.next()); // (No generics be

zijin613的专栏 904

8.46 优先使用for-each循环代替for循环

使用for-each循环更简洁,进而减少错误,对比如下: Collection&lt;String&gt; parents=new ArrayList&lt;String&gt;(); Collection&lt;String&gt; childs=new ArrayList&lt;String&gt;(); for(Iterator&lt;String&gt; p=p...

bingooh的专栏 233

2015062906 - EffactiveJava笔记 - 第46条 foreach优先传统for循环(2)

对多个集合嵌套迭代,for-each比for优势更明显.     enum Suit { CLUB,DIAMOND,HEART,SPADE }     enum Rank { ACE, DEUCE, THREE, FORE, FIVE, SIX,SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING}       class Card {        pu

bellsky 361

2015062908 - EffactiveJava笔记 - 第46条 foreach优先传统for循环(4)

有三种情况无法使用for-each循环,此时只能使用传统for循环.     1.过滤,如果需要遍历集合,然后删除选定元素,此时只能使用显示的迭代器,以便可以调用remove方法.     2.转化,如果需要遍历列表或者数组,并取代它部分或者全部的元素值,就需要列表迭代器或者索引,以便设定元素数值.     3.平行迭代,如果需要并行迭代多个集合,就需要显式地控制迭代器或者索引值,以便所有迭

bellsky 321

Effective Java读书笔记--for-each循環優先于for循環

 package chape8; /** * 第8章 * 第46條: * for-each循環優先于for循環 * for(Element e : c) * { * dosomthing(e); * } * 这个是java1.5以上的版本的for循环的首先考虑的写法 * 以下是java1.5以前的寫法 *  for (Iterator it = c.iterator();it.hasNext(

wwwwap2008的专栏 422

2015062907 - EffactiveJava笔记 - 第46条 foreach优先传统for循环(3)

for-each循环不仅可以遍历数组和集合,任何实现Iterable接口的类都可以使用for-each循环遍历.用户会非常感激你的.     Iterable接口是单方法组成,代码如下:     public interface Iterable{        Iteratoriterator();     }         for-each在简洁性和预防bug方面比传统fo

bellsky 337
上一篇: 第11条 谨慎地覆盖clone
tiepiche
博客等级 码龄10年 3粉丝 12原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址