java - Selection Sort method error, incompatible types -
here code far. getting incompatible type in first statement. required: boolean found: int
not quite sure need prepare this.
public void selectionsort(int[] list){ //implement selection sort here. (int = 0;list.length -1;i++){ int smvi = i; for(int j = i+1;j<list.length;j++){ if(list[j] < list[smvi]){ smvi=j;} if(i!=smvi){ int temp = list[i]; list[i] = list[smvi]; list[smvi] = temp; } } } }
the problem here: list.length -1
what think want i <= list.length - 1
java sorting selection-sort
No comments:
Post a Comment