How do you set one array’s values to another array’s values in Java?

You may want to use clone:

a = b.clone();

or use arraycopy(Object source, int sourcePosition, Object destination, int destinationPosition, int numberOfElements)

System.arraycopy(b, 0, a, 0, b.length());

Leave a Comment