Write a bubble sort in java

I can provide you a simple Java code to implement bubble sort: public class BubbleSort {public static void main(String[] args) {int array[] = {2, 5, -2, 6, -3, 8 , 0, -7, -9, 4};int n = array.length;int temp = 0;for(int i=0; i < n; i++){for(int j=1; j < (ni) ; j++){if(array[j-1] > array[j]){temp = array[j-1];array[j-1] = array[j];array

Guess you like

Origin blog.csdn.net/weixin_42584507/article/details/129606459