0

I have an arraylist

ArrayList<int[]> strokeLines = new ArrayList<int[]>();

and a function which runs everytime the mouse is clicked which adds the current mouse position and the previous mouse position to this arraylist

strokeLines.add({mouseX, mouseY, pmouseX, pmouseY});

I had this code working earlier but I lost everything I wrote in the past hour, and when I rewrote this part it wouldn't work. How can I add the array {mouseX, mouseY, pmouseX, pmouseY} to the end of the arraylist?

2 Answers 2

3

You need to create a new int[]:

strokeLines.add(new int[]{mouseX, mouseY, pmouseX, pmouseY});
Sign up to request clarification or add additional context in comments.

Comments

1

Simply -

strokeLines.add(new int[]{mouseX, mouseY, pmouseX, pmouseY});

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.