The code to return the integer array reversed. I think its entirely correct, But its not working.
The code is not entering into the for(int j=3; j==0; j--) loop.
CODE:
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] arr = new int[n];
int[] rev = new int[n];
for(int i=0; i < n; i++)
{
arr[i] = in.nextInt();
System.out.println( "Here"+ arr[i]);
for(int j=3; j==0; j--)
{
System.out.println(j);
System.out.print( "Resevre1 "+ rev[j]);
if (j+i==3)
{
rev[j] = arr[3-i];
System.out.print( "Resevre Here"+ rev[j]);
}
}
}
in.close();
}
}
Sample Input
4
1 4 3 2
Sample Output
2 3 4 1
for(int j=3; j==0; j--)means you tantalizejto 3 and execute the loop as long asjequals 0.