Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
368 B
3
Indexable
Never
public class Array_prac3{
public static void main(String[]args){
  int arr[] = { 1,2,3,4,5};
  int reversed []= new int [arr.length];
  for ( int i = 0; i<arr.length; i++){
    reversed [arr.length-1-i]=arr[i];
  }
  arr = reversed;
  System.out.print("Reversed array : ");
  for ( int i = 0; i<arr.length; i++){
    System.out.print(arr[i]+" ");
  }
 }
}
Leave a Comment