У меня проблема с bubbleSort () в Java. Что не сортирует массив
import java.util.*;
public class Example {
public static void bubbleSort(int[] x){
for(int i=0; i<x.length-1; i++){
if(x[i]>x[i+1]){
int t=x[i];
x[i]=x[i+1];
x[i+1]=t;
}
}
}
public static void main(String[] args) {
int[] xr={99,78,67,12,65,54,43,23,67,11};
System.out.println(Arrays.toString(xr)); //99,78,67
bubbleSort(xr);
System.out.println(Arrays.toString(xr)); //11, 12, 23, 43,
}
}
Это вывод данного кода:
[99, 78, 67, 12, 65, 54, 43, 23, 67, 11]
[78, 67, 12, 65, 54, 43, 23, 67, 11, 99]