Skip to content

Instantly share code, notes, and snippets.

@syedjafer
Created April 28, 2021 11:39
Show Gist options
  • Select an option

  • Save syedjafer/abcdca95c478b3b38ccc288af16b4a31 to your computer and use it in GitHub Desktop.

Select an option

Save syedjafer/abcdca95c478b3b38ccc288af16b4a31 to your computer and use it in GitHub Desktop.
import java.util.*;
public class Main {
/*function reverses the elements of the array*/
static void reverse(Integer myArray[])
{
Collections.reverse(Arrays.asList(myArray));
System.out.println("Reversed Array:" + Arrays.asList(myArray));
}
public static void main(String[] args)
{
Integer [] myArray = {1,3,5,7,9};
System.out.println("Original Array:" + Arrays.asList(myArray));
reverse(myArray);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment