Java,如何在“for each”循环中获取当前索引/键
2022-08-31 05:12:54
在Java中,如何获取Java中元素的当前索引?
for (Element song: question){
song.currentIndex(); //<<want the current index.
}
在 PHP 中,你可以这样做:
foreach ($arr as $index => $value) {
echo "Key: $index; Value: $value";
}