2

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?

1
  • Sorry about that! I don't use Stack Overflow that often so I wasn't aware you could do that. Commented Sep 28, 2021 at 16:41

1 Answer 1

1

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));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.