public class MyClass {
static void bubbleSort(int[] arr) {
int len = arr.length;
for (int i = 0; i < len - 1; i++) {
for (int j = 0; j < len - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
public static void main(String args[]) {
int[] arr = {6, 8, 0, 3, 1, 6, 4};
bubbleSort(arr);
for (int n : arr) {
System.out.printf("%2d", n);
}
}
}
/*
run:
0 1 3 4 6 6 8
*/