I was trying to implement my own ArrayList class for educational purposes and when I need to make it grow I need to copy the contents of the old small array into the new bigger one.
Doing this with a for loop is very inefficient and would require O(n) time depending on the size of the array to be copied. Luckily Java has the System.arraycopy() function which I suspect doesn't use a for loop but copies the entire array at once taking way less time.
However is it possible for myself to do these kind of memory copies or is this so deeply buried that only the java compiler can do this?
P.S there are a lot of functions that I don't know how to implement and seem to work using magic System.out.println() for example or sockets.
For clarification I just want to know how i can do these kind of omptimized memory managments things myself.