I am working with collection in which I'm trying to reverse a list and getting error as :
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 6, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at com.java.commonMethods.CommonClass.rev(CommonClass.java:22)
    at com.java.commonMethods.CommonClass.reverse(CommonClass.java:27)
    at com.java.commonMethods.CallToCommonMethods.callToCount(CallToCommonMethods.java:24)
    at com.java.commonMethods.CallToCommonMethods.main(CallToCommonMethods.java:42)
and u can check the code to i'm using to reverse as:
public static <E> void rev(List<E> list) {
        List<E> temp = new ArrayList<E>();
        for (int i = 0; i <= list.size(); i++) {
            list.set(i, temp.get(list.size() - i - 1));
        }
    }
    public static void reverse(List<?> list) {
        rev(list);
    }
and simply this is the call :
List<Integer> listInteger = Arrays.asList(0,1,2,3,4,5);
        CommonClass.rev(listInteger);
        System.out.println(listInteger);
can anyone tell me the cause of problem? and please tell me how is it causing problem and how to fix this issue.. thanks.
 
    