Question: The following code shifts all characters in a character array one place to the right, and moves the last character to the front: public static

The following code shifts all characters in a character array one place to the right, and moves the last character to the front:

 public static void shift ( char [] str) { int len = str.length;  //Assume string is not empty  char last = str[len- 1]; for ( int i = len - 1; i > 0; i--) { str[i] = str[i- 1]; } str[ 0] = last; } 

Completely rewrite the code so that it shifts all characters one place to the left, and moves the first character to the end of the character array. You can assume the string contains at least one character.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!