public class BubbleSort {
public static void main(String args[]) {
int a[] = { 2, 4, 6, 8, 2, 4, 1, 0, 9 };
for (int i = 0; i < a.length; i++) {
for (int j = i + 1; j < a.length; j++) {
if (a[i] > a[j]) {
int temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
for (int i : a) {
System.out.println("i=" + i);
}
}
}
转载于:https://blog.51cto.com/kingfly/386719