I just got bit by using .clone() on my 2d boolean array, thinking that this was a deep copy.
.clone()
boolean
How can I perform a deep copy of my bool
bool
In Java 8 this can be accomplished as a one-liner using lambdas:
T[][] deepCopy(T[][] matrix) { return java.util.Arrays.stream(matrix).map(el -> el.clone()).toArray($ -> matrix.clone()); }