Changes made for rightward shift:
Store the last element (temp = words[words.length - 1];).
Shift all elements right (words[index] = words[index - 1];), so each element moves to the next position.
Place the last element at the beginning (words[0] = temp;).
if (array[i] > array[i - 1]) {
System.out.println("Increase");
}
Changes made for rightward shift: Store the last element (temp = words[words.length - 1];). Shift all elements right (words[index] = words[index - 1];), so each element moves to the next position. Place the last element at the beginning (words[0] = temp;).
if (array[i] > array[i - 1]) { System.out.println("Increase"); }