Reputation: 27
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]
Upvotes: 0
Views: 90
Reputation: 7071
You can look at the implementation here
Basically in the end it uses System.arraycopy
which has a complexity of O(n)
Upvotes: 1