I could not understand why this code is giving ArrayIndexOutOfBoundsException. here is my code to implement bidirectional bubble sort.
static void bubble(int[] a){
int temp;
for(int i=a.length-1,k=0;i!=k;i--,k++){
for(int j=k;j<i;j++){
if(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
for(int j=i-1;j>k;j--){
if(a[j-1]>a[j]){
temp=a[j];
a[j]=a[j-1];
a[j-1]=temp;
}
}
}
}