class BubbleSort
{
void bubbleSort(int arr[])
{
int n = arr.length;
for (int i = 0; i < n-1; i++)
for (int j = 0; j < n-i-1; j++)
if (arr[j] > arr[j+1])
{
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
void display(int arr[])
{
int n = arr.length;
for (int i=0; i<n; ++i)
System.out.print(arr[i] + " ");
System.out.println();
}
public static void main(String args[])
{
BubbleSort obj = new BubbleSort();
int arr[] = {32, 34, 15, 72, 12, 83, 90, 43, 62};
System.out.println("Given array:");
obj.display(arr);
obj.bubbleSort(arr);
System.out.println("\nSorted array:");
obj.display(arr);
}
}