List<color> cr = new ArrayList<color>(); Why does the above code show me Error on Dimensions?
List<color> cr = new ArrayList<color>(); Why does the above code show me 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); } Why ?
ArrayList can only reference types, not primitives. Integer is a class, not a primitive.
More details in this answer
In this case the color datatype is a primitive.