I am wondering if this method of adding to primitive array is still constant time?
char[] arrayA = {'b', 'c'};
char[] arrayB = ArrayUtils.add(arrayA, 0, 'a');
// arrayB: [a, b, c]
I am wondering if this method of adding to primitive array is still constant time?
char[] arrayA = {'b', 'c'};
char[] arrayB = ArrayUtils.add(arrayA, 0, 'a');
// arrayB: [a, b, c]
You can look at the implementation here
Basically in the end it uses System.arraycopy which has a complexity of O(n)