Why do I get ArrayIndexOutOfBoundsException: 1in my Insertion sort on this line: while ((a[j].compareTo(a[j - 1]) > 0) && j > 0)
 public static <T extends Comparable> void inserionSort(T[] a) {
            int j, i;
            for (i = 1; i < a.length; i++) {
                //initial condition 
                j = i;
                while ((a[j].compareTo(a[j - 1]) > 0) && j > 0) {
                     
                    swap(j, j - 1, a); 
                    j--;
                }
                 
            }
            display(a);
    
        }
Is there any problem with my algorithm?
 
     
    