C # Java version Array.Copy (Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)

I am trying to convert C # code to Java and I came across a line that calls this method:

Array.Copy( frames[row], 0, concatenated, row*frames[row].Length, frames[row].Length); 

The signature of the C # method is as follows:

 Array.Copy( Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) 

I am trying to find a way to do the same in Java without any luck. How can I simulate the same behavior in Java?

+4
source share
1 answer

Have you tried System.arraycopy() ?

Example:

  char[] copyFrom = { 'd', 'e', 'c', 'a', 'f', 'f', 'e', 'i', 'n', 'a', 't', 'e', 'd' }; char[] copyTo = new char[10]; System.arraycopy(copyFrom, 1, copyTo, 2, 8); System.out.println(new String(copyTo)); 

The output will be:

  ecaffein 
+4
source

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


All Articles