有一个数组有n个数,使其前面各数向后移动m位。移动后后面的数补充到前面去

package TestFor0322;

public class Demo1For数组元素移动 {

    /**
     * 有一个数组有n个数,使其前面各数向后移动m位。移动后后面的数补充到前面去
     */
    public static void main(String[] args) {
        char n[]={'a','b','c','d','e','f','g','h'};
        int m=3;
        ArrayMove(n,m);
    }

    private static void ArrayMove(char[] n, int m) {
        
        char[]temp2=new char[n.length];
        for(int i=0;i<m;i++){
            temp2[i]=n[n.length-m+i];
        }
        for(int i=m;i<n.length;i++){
            temp2[i]=n[i-m];
        }
        System.out.print(temp2);
    }

}
原文地址:https://www.cnblogs.com/DeepBlues/p/2974807.html