For a project i'm working on, I have two grids formed by 2D Arrays, one of which allows the user to draw an image into it, the other displays the last image submited. However my code is making a shallow copy of it instead of a deep one, and I need to find a way to deep copy in Processing. Here's a snippet of my shallow copy code:
for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {
mainGrid[i][j] = userGrid[i][j];
}
}
What's the simplest way of doing this in Processing? I've been searching extensively for the simplest way for me to deep copy all the contents of my userGrid into my mainGrid, such as using the Java Deep-Copy library, but I'm not quite sure how to use the tools of this library to copy a 2D array into another one.