Q:

Java Program to reverse an array

0

Program to reverse an array of integer values.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Arrays; 
public class demo1 
{
 public static void main(String[] args)
 {   
  int[] array = {2,23,4,5,211,455,12};
  System.out.println("Original array : "+Arrays.toString(array));  
  for(int a = 0; a < array.length / 2; a++)
  {
    int temp = array[a];
    array[a] = array[array.length - a - 1];
    array[array.length - a - 1] = temp;
  }
    System.out.println("Reverse array : "+Arrays.toString(array));
 }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now