class ArrayTest2
{
public static void bubbleSort(int [] arr)
{
for (int x=0;x<arr.leng-1 ;x++ )
{
for (int y = 0;y<arr.length-x-1 ; y++)
{
if(arr[y]>arr[y+1])
{
int temp = arr[y];
arr[y] =arr [y+1];
arr[y+1]=temp;
}
}
}
}
public static void main(String[] args)
{
int[] arr = {5,1,6,4,2,8,9};
printArray(arr);
//selectSort(arr);
bubbleSort(arr);
printArray(arr);
}
} |