I have made a Bubble Sort for ints.
my next step is to make my Bubble Sort
more sophisticated by making it work
for a generic array. I have to write a
test program for my method using arrays
with these three data types: Double, Character, and String.
so far i have
public class Sort {
public static void main(String[] args) {
int array[] = { 23, 12, 466, 22,1,2,3,4,56,2,6,4 };
int temp;
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]) {
temp = array[j + 1];
array[j + 1] = array[j];
array[j] = temp;
}
}
}
System.out.println("Sorted Array");
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}
thanks in advance for all help!

New Topic/Question
Reply



MultiQuote







|