作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
public void display(detailTom tomData)
{
ArrayList<detailTom> temp = new ArrayList<detailTom>();
for (int i=0;i<tomData.toString().length();i++)
{
temp=tomData[i];
System.out.println(temp.getMark1());
}
}
大家好,
我正在尝试迭代数组列表 tomData,它是一个对象数组列表。我正在尝试迭代列表并显示对象“Mark1”的变量。
错误是“需要数组,但找到了detailTom”
有什么想法吗?或者通过 tomData 进行迭代的任何其他方式?
最佳答案
您提供的内容并没有真正意义,但根据评论,我猜测您正在寻找的答案如下所示:
public void display(List<DetailTom> tomData) {
for (DetailTom detail : tomData) {
System.out.println(detail.getMk1());
}
}
我已将您的类从 detailTom
重命名为 DetailTom
,就像 convention in Java 一样。 :
Names of class types should be descriptive nouns or noun phrases, not overly long, in mixed case with the first letter of each word capitalized.
关于java - 遍历数组列表 - java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22749336/
我是一名优秀的程序员,十分优秀!