public class bubblesort{ //consult wikipedia what is bubblesort if you do not know
    public static int N=6;
    public static int [] c = {0,4,-1,2,8,4};  //array of ints to be sorted
    
    public static void swapNeighbors(int i){ //swaps value at index i with its next neighbor
        int tmp = c[i];
        c[i]=c[i+1];
        c[i+1]=tmp;
    }
    
    public static void main(String[] args){
        boolean done = true;
        do{
            done=true;  //assume no swap will be needeed
            for(int i = 0; i<N; i++){  //this will lead to run-time error! Correct it!
                if (c[i]>=c[i+1]) {  //another error here: find the logic error in this line!
                    swapNeighbors(i);
                    done=false;
                }
            }
        }while(!done);
        for(int i = 0; i<N; i++){
            System.out.print(c[i]+",");
        }
        System.out.println("");
    }
    
}
