This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The below snippet of code throws a nullPointerException but if I replace with the following snippet of code it "works" but the array points to the array passed in and that's no good because the array coming in needs to change on each call. How can I effectively copy the array into the instance array lineCoords?
If you look at the documentation for arraycopy, you'll see that you can't pass a null value in for the array. You've got to create the array first (at the size you want). If you think about it, that has to be the case as you're passing the reference by value. If you pass null in, it can't possibly result in lineCoords pointing at a new object.
However, I suggest you check Arrays.copyOf instead, as that will create the array for you.
If you are sure about the size of the array you want to pass, you could just make aan array of that size, make lineCoords, point to it, and then copy the elements of coords to it. Although its is a bit cumbersome, I beleive their must be easier methods...
If debugging is the process of removing bugs, then programming must be the process of putting them in. -- Edsger Dijkstra