核心代码:
public void bubbleSort(){ for(int i=0;ia[j+1]) swap(j,j+1); } } } public void swap(int indexa,int indexb){ int temp = a[indexa]; a[indexa] = a[indexb]; a[indexb] = temp; }
主要代码
class Array{ private int[] a; private int length; public Array(int max){ a = new int[max]; length = 0; } public void insert(int value){ a[length] = value; length++; } public void dispaly(){ for(int i=0;i
执行示例