Skip to content

Instantly share code, notes, and snippets.

@mounicasrinivas
Created December 24, 2023 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mounicasrinivas/121b535f005af0f073a3239f727d5728 to your computer and use it in GitHub Desktop.
Save mounicasrinivas/121b535f005af0f073a3239f727d5728 to your computer and use it in GitHub Desktop.
Reverse An Array
public class ReverseAnArray {
public static void main(String[] args) {
int [] a = {1,2,3,4,5};
int [] rev = new int [a. length];
for(int i = 0; i< a.length; i++){
rev[i] = a[a.length -1 -i];
}
for(int v: rev){
System.out.println(v + "");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment