Andr7st

Andr7st

Copying and comparing arrays: shallow copy, clone and equals

Copying and comparing arrays: shallow copy, clone and equals

Why b = a copies nothing, what clone() does with an array of objects, when to use System.arraycopy or Arrays.copyOfRange, and why equals() on arrays is almost never what you want — but Arrays.equals and deepEquals are.


Written by
Andrés Segura
Id

jaa06

Posted

Sep 25, 2026

Reading time

6 min

java
arrays
cloning
equality
On this page
Loading...