Hi -
There's something wrong with your algorithm. Here's a slightly modified version that works (albeit with typical bubble sort lack of efficiency ;-)):
Code:
public class Bubble {
public static void main (String[] args) {
int[] array = { 3,7,1,5,3,8,2 };
for (int i = 0; i < array.length-1; i++) {
for (int j = 0; j < array.length-1-i; j++) {
if (array[j+1] < array[j]) {
int temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
for (int i = 0; i < array.length-1; i++) {
System.out.println ("a["+ i + "]: " + array[i] + "...");
}
}
}
'Hope that helps .. PSM
PS:
Please be sure you use "[code]" tags in future LQ posts!