Created
December 24, 2023 17:11
-
-
Save mounicasrinivas/121b535f005af0f073a3239f727d5728 to your computer and use it in GitHub Desktop.
Reverse An Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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