List<color> cr = new ArrayList<color>();
为什么上面的代码显示我Error on Dimensions
?
使用整数而不是颜色:
import java.util.*;
List<Integer> cr = new ArrayList<Integer>();
//populate list
for(int i = 0 ; i < 100; i++){
cr.add(color(random(255),random(255),random(255)));
}
//retrieve values from list
for(int i = 0 ; i < 100; i++){
fill(cr.get(i));
rect(i % 10 * 10, i / 10 * 10,10,10);
}
为什么?
ArrayList 只能引用类型,不能引用基元。整数是一个类,而不是基元。
此答案中的更多详细信息
在这种情况下,颜色数据类型是基元。