这是我到目前为止所拥有的,但是当我运行它时,我得到一个 Java 不匹配错误。这是我的数组:
char[] letters = {'A', 'B' , 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'};
/********************************************************************************
shiftRight() will move the contents of the array one slot to the right
********************************************************************************/
public static void shiftRight( char [] letters )
{
char last = letters[letters.length-1]; // save off first element
// shift right
for( int index =letters.length-1; index >= 0 ; index-- )
letters[index+1] = letters [index];
// wrap last element into first slot
letters[0] = last;
System.out.print("\nshifted Array: " );
}