My code is as so...
ArrayList<Ray> rays = new ArrayList<Ray>();
Particle() {
for(int a=0; a < 360; a =10) {
append(rays, new Ray(position, radians(a)));
}
}
I'm initializing an ArrayList of the class Ray. Then I run through a for loop and am attempting to
append a new Ray() to the list. I get no errors in the editor but whenever I run the code I get the error message: IllegalArgumentException: Argument is not an array
I've looked around and nothing seems to answer my question. Why is this happening?
CodePudding user response:
The append
function is for use with arrays (e.g.: rays[]
). However rays
is an ArrayList
. Hence, you need to use the add
method:
append(rays, new Ray(position, radians(a)));
rays.add(new Ray(position, radians(a));