I'm trying to write a method that will rotate a set of values in an array. For example, say I have {1, 2, 3, 4, 5, 6}... it should print {5, 6, 1, 2, 3, 4}
Here's what I have so far and it prints weird characters:
Here's what I have so far and it prints weird characters:
Code:
public static void rotate(int[] values, int distance)
{
for (int i = 0; i < distance; i++){
int temp = values[0];
int j = 0;
for(j = i; j < distance - 1; j++){
values[j] = values[j + 1];
}
}
System.out.println(values);
}