插入排序
import java.util.*; public class Insert{ public void getInsert(int[] array){ if(array == null || array.length == 0) return; int j=0; for(int i=1;i<array.length;i++){ int temp = array[i]; for(j=i;j>0&&(array[j-1]>temp);j--){ array[j]=array[j-1]; } array[j] = temp; } } public static void main(String[] args){ int[] array = {9,8,7,6,5,4,3,2,1}; Insert i = new Insert(); i.getInsert(array); System.out.println(Arrays.toString(array)); } }