采用增强for循环遍历list或者set,如果list或者set没有加泛型,能遍历吗

如题所述

可以,遍历的时候用Object就行

List students = new List();
int index = 1;
for (Object student: students) {
    System.out.println(index++);
}

温馨提示:内容为网友见解,仅供参考
第1个回答  2017-08-11
有Iterator就可以

~
~
~
~
相似回答