【发布时间】:2011-03-26 18:46:46
【问题描述】:
在 Java 中,如何获取 Java 中元素的当前索引?
for (Element song: question){
song.currentIndex(); //<<want the current index.
}
在 PHP 中你可以这样做:
foreach ($arr as $index => $value) {
echo "Key: $index; Value: $value";
}
【问题讨论】:
-
这个问题大约每月被问一次
-
在 PHP 中,您使用的关联数组不是 Java 数组的同义词。
-
Arrays.asList(question).indexOf(song)
标签: java