System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length) is a native method.
System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
What is the time complexity for this method?
It will have to go through all the elements in the array to do this. Array is a unique data structure where you have to specify a size when you initialize it. Order would be the source array's size or in Big O terms its O(length).
Infact this happens internally in an ArrayList. ArrayList wraps an array. Although ArrayList looks like a dynamically growing collection, internally it does an arrycopy when it has to expand.
1.4m articles
1.4m replys
5 comments
57.0k users