Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ReverseArray {
- public static void main(String[] args) {
- int [] arr = new int [] {1, 2, 3, 4, 5};
- System.out.println("Original array: ");
- for (int i = 0; i < arr.length; i++) {
- System.out.print(arr[i] + " ");
- }
- System.out.println();
- System.out.println("Array in reverse order: ");
- for (int i = arr.length-1; i >= 0; i--) {
- System.out.print(arr[i] + " ");
- }
- }
- }
Add Comment
Please, Sign In to add comment