- /**
- *
- */
- package exercise;
- /**
- * @author bin
- *
- */
- public class RegexDemo {
- public static void main(String[] args) {
- int [] src= {2,3,6,5,4,5,2,1,3,2,1,2,1,5,4,6,2,1,3,22};
- int [] dest= {10,12,25,45,65,21,32,65,45,84,515,959};
- arraycopy(src,5,dest,6,10);
- }
- public static void arraycopy(int[] src,int srcPos,int[] dest,int destPos,int length){
- if((destPos+length)<dest.length) {
- for(int i=0;i<length;i++) {
- dest[destPos+i]=src[srcPos+i];
- }
- }
- else {
- System.out.println("给定的dest数组长度不足以容纳拷贝的数字");
- }
- for(int i=0;i<dest.length;i++) {
- System.out.print(dest[i]+" ");
- }
- }
- }
复制代码 |