0% found this document useful (0 votes)
5 views1 page

Reverse Elements in an Array Program

The document contains a Java program that reverses the elements of an array. It initializes an array with values 1 to 5, prints the original array, and then prints the reversed array. The output demonstrates the original and reversed arrays clearly.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Reverse Elements in an Array Program

The document contains a Java program that reverses the elements of an array. It initializes an array with values 1 to 5, prints the original array, and then prints the reversed array. The output demonstrates the original and reversed arrays clearly.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Write a program to reverse the elements present in an

array.

Public class ReverseArray {

Public static void main(String[] args) {

Int[] arr = {1, 2, 3, 4, 5};

[Link](“Original Array: “);

For (int I : arr) {

[Link](I + “ “);

[Link](“\nReversed Array: “);

For (int I = [Link] – 1; I >= 0; i--) {

[Link](arr[i] + “ “);

Output
Original Array: 1 2 3 4 5
Reversed Array: 5 4 3 2 1

You might also like