I was wondering if you can help me around this code. It should reverse content of array but I get this. Does anyone know how to fix this?
import java.util.Arrays;
public class Arrays7 {
public static void main(String[] args) {
// Write a Java program to reverse an array of integer values.
int arr[] = { 1, 2, 3, 4, 5};
int petlja[] = { 0, 0, 0, 0, 0 };
/* arr[0] = petlja[4];
arr[1] = petlja[3];
arr[2] = petlja[2];
arr[3] = petlja[1];
arr[4] = petlja[0];
*/
for ( int i=4; i>0; i--) {
for ( int j=0; j<4; j++) {
petlja[j] = arr[i];
}
}
System.out.println(Arrays.toString(petlja));