/ Published in: Java
Does the same as `System.arraycopy(source, copyFrom ,target, copyTo, length)` but without worrying about invalid input. Example for an array of characters.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public void arraycopy(char[] source, int copyFrom, char[] target, int copyTo, int length) { // Input validation if(source == null || target == null) return; if(copyFrom+length >= source.length || copyTo+length > source.length) return; // Same as: System.arraycopy(source, copyFrom, target, copyTo, length); for(int i=0;i<length;i++) { target[copyTo+i] = source[copyFrom+i]; } }