如何使用数组的索引值遍历ArrayList(正在处理) [英] How to loop over an ArrayList using the index value of an Array (Processing)
本文介绍了如何使用数组的索引值遍历ArrayList(正在处理)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
for (int i=0; i<years.length; i++)
{
//code to display each year
for (int j = years[i].xrateValue.size ()-1; j >= 0; j--)
{
float xrate = (float)(years[i].xrateValue.get(j));
float barHeight = map(xrate, 0, mathMax, 0, 80); //adjust rect size
float bX = sX+2;
float bY = sY + 105 - barHeight;
float bW = 105 / years.length;
strokeWeight(0.9);
stroke(10);
fill(255, 8, 8);
if (xrate >= 71)
{
fill(2, 152, 48);
} else if ((xrate >= 51) && (xrate <= 70))
{
fill(255, 217, 19);
}
rect(i+i+i+bX, bY, bW, barHeight);
}
}
推荐答案
for(int i : [listname]){
for(int j = i; j > 0; j--){
// your code
}
}
这将重复重复一次重复,每次重复重复一次(哇,这太令人困惑了。就把它读一遍,直到它明白为止。
这篇关于如何使用数组的索引值遍历ArrayList(正在处理)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文