How do I reverse an int array in Java

Following program reverses an int array.

Example

public class Tester {
   public static void main(String[] args) {
      int[] numbers = {1,2,3,4,5};

      //swap the numbers till the midpoint comes
      for (int start = 0, end = numbers.length - 1;
      start 

Output

5 4 3 2 1
Updated on: 2020-02-24T10:35:31+05:30

247 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements