22智能在线
新记
采用增强for循环遍历list或者set,如果list或者set没有加泛型,能遍历吗
如题所述
举报该文章
相关建议 2017-08-11
可以,遍历的时候用Object就行
List students = new List();
int index = 1;
for (Object student: students) {
System.out.println(index++);
}
温馨提示:内容为网友见解,仅供参考
当前网址:
https://22.t2y.org/zz/c2c22s0fs06xxh2x6ih.html
其他看法
第1个回答 2017-08-11
有Iterator就可以
~
~
~
~
相似回答
大家正在搜
相关问题
Java中Set集合怎样用for遍历?
采用增强for循环遍历list或者set,如果list或者s...
增强for循环里面我如何取得第i个值
struts2<s:iterator>遍历一个l...
java里set list 为什么能遍历集合
for循环倒着遍历有什么好处
java中使用增强型的for循环有什么好处?
java中增强for循环是怎么回事?