Building an efficient bubble sort function
Instead of using a regular for loop to loop through array:


for(int i=0; i&lt;array.length; i++)
{
    System.out.print(array[i] + " ");
}



you can use a nicer foreach loop:

for (int i : array)
{
    System.out.print(i + " ");
}