Java memmove?

I am porting old code to Java and, due to my inexperience with Java, I ran into the problem of posting the equivalent of memmove. Is there such a method in Java? I have done enough research on this to suggest that I am missing out on something pretty obvious. Thanks in advance.

+4
source share
2 answers

You can use System.arraycopy if all you want to do is mix things around the array.

In particular, this function allows the source and target objects to be in the same array, and ranges are allowed to overlap; therefore, in this sense, it is similar to memmove .

+10
source

Actually, System.arrayCopy() is an old school approach to this, and it should be used only if you a) are stuck in Java 5 or earlier, or b) are forced to copy between pre-existing arrays. If you want to create a copy of the array, you can use Arrays.copyOf() or Arrays.copyOfRange()

+4
source

Source: https://habr.com/ru/post/1286530/


All Articles