如何在java或C ++中迭代arraylist? [英] How does iterating through an arraylist work in java or C++?

查看:68
本文介绍了如何在java或C ++中迭代arraylist?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);

for (int i = 0; i < list.size(); i++) {
	System.out.println(list.get(i));
}

for (Integer elem : list) {
	System.out.println(elem);
}
ist.forEach(new Consumer<Integer>() {
    @Override
	public void accept(Integer elem) {
        System.out.println(elem);
    }
});





我尝试过:





What I have tried:

List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);

for (int i = 0; i < list.size(); i++) {
	System.out.println(list.get(i));
}

for (Integer elem : list) {
	System.out.println(elem);
}
ist.forEach(new Consumer<Integer>() {
    @Override
	public void accept(Integer elem) {
        System.out.println(elem);
    }
});

推荐答案

引用:

如何在java或C ++中迭代arraylist工作?

How does iterating through an arraylist work in java or C++?



这个问题有一些问题,因为'数组如何工作'是阵列101,阵列102.

我能想到的唯一解释是你通过跳过一些课程让你轻松学习。

确实首先,跳过课程为你节省了一些学习时间。

但是后来你发现缺少一些知识,你开始花更多的时间来学习那些缺少的知识。更糟糕的是,你也浪费了其他人的时间。



数百万人学习了编程,所以课程是学习它的简单方法。



我们不可能写出比课程更好的解释。

问题说你错过了阵列概念的一个非常基本的部分,只有一个与老师或导师交谈可以准确地发现你不理解的东西并给予补救。


There is something very wrong in the question, because 'how arrays works' is array 101, array 102.
the only explanation I can think of is that you have made your easy way of learning by skipping some lessons.
Indeed in first, skipping lessons saved you some learning time.
But later you see that some knowledge is missing, and you start to spend more time to learn that missing knowledge. Worse is that you also waste other people time.

Millions of people have learned programming, so courses are the easy way to learn it.

We can't possibly write an explanation better than what is in courses.
The question says that you are missing an extremely fundamental part of the array concept, only a talk with a teacher or tutor can spot exactly what you don't understand and give remedy.


这篇关于如何在java或C ++中迭代arraylist?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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