public class Main {

   public static void main(String[] args) {

       char[] testArray = {'a','b','c','d','e','f','g'};

       // Rotate the testArray 5 spaces
       for(int i=0;i<8;i++){
           System.out.println(rotate(testArray,i));
       }
   }

   /**
    * Method to Rotate a array of Characters n positions to the RIGHT.
    * Elements at the end of the array move to the fron of the array.
    * @param ary, An Array of Characters
    * @param k, the number of positions to rotate the elements in the array (to the right)
    * @return An array of Character with the elments rotated k number of positions.
    */
   public static char[] rotate(char[] ary, int k){

       char[] buffer = new char[ary.length];

       for(int i=0;i<ary.length;i++){
           buffer[((i+k)%ary.length)]=ary[i];
       }

       return buffer;

   }

}