简体   繁体   中英

adding array of integers to ArrayList<int[]>

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?

您需要创建一个新的int[]

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

简单地-

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM