Whats wrong with this code???
Code:
public class Try {
public static void main(String[] args) {
//create an integer array
Integer[] intArray = {new Integer(2), new Integer (4),new Integer(4), new Integer (3)};
sort(intArray);
printList(intArray);
}
public static void sort(Comparable list[]){
Comparable currentMax;
int currentMaxIndex;
for(int i = 0; i < list.length -1; i++){
for (int j = 0; j <list.length; j++){
if(list[i].compareTo(list[j]) < 0){
Comparable temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
}
}
public static void printList(Object[] list){
for(int i = 0; i <list.length; i++){
System.out.print(list[i] +" ");
System.out.println();
}
}
}
Whats wrong ,, please help ??:confused::confused:
Moderator Edit: Code tags corrected