I thought Arrays are static, i.e. they cannot be increased or decreased in element size. How come when I declare an array of x elements, I can copy an array of y>x elements into my new array like so:
import java.util.Arrays;
public class CopyOf {
public static void main(String[] args) {
int[] array ={4,5,4,65,465,4,56,456,6,43,3,5,45};
//copiedArray has 4 elements
int[] copiedArray = new int[4];
copiedArray = Arrays.copyOf(array, array.length);
// copiedAarray now has 13 elements
System.out.println(Arrays.toString(copiedArray));
}
}