Q:

can not reverse ordering the array in java

can not reverse array values in another array
please guide me how to inverse the array values in another array
i have used the swap method with a temp variable also, but it wasn't effective
import java.util.Scanner;

public class ArrayHW {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Scanner in = new Scanner(System.in);

        System.out.println("please enter the lenght of the array:");

        int len = in.nextInt();

        int k = 0 ;

        int[] array = new int [len];
        int[] invarr = new int[len];

        for( int i = 0; i < len ; i++ ){

        System.out.println("please enter the values:");
        array[i] = in.nextInt();
        }

        //using for loop
        for( int i=0 ; i < len ; i++ ){
            System.out.println("the array in normal case is:" + (i+1) + "\t" + array[i]);

        }

        /*for (int nav : array) {
            System.out.println(nav);
        }*/

        for( int i = len ; i >= 0 ; i--)
        {
            invarr[k] = array[i];
            System.out.println(invarr[k]);              
            k++;                
        }

    }

}

A:

You can use reverse method from Collections util class
List < Object > list = Arrays.asList(arr);
Collections.reverse(list);
Object[] res = list.toArray();

A:

You may be experiencing IndexOutofBoundException because your loop to reverse the array starts with i=len. Arrays are traversed from len-1 to 0. So change your loop to:
for( int i = len -1; i >= 0 ; i--)
{
    invarr[k] = array[i];
    k++;
}

