package ch02;
public class BublleSort {
public static void sort(long [] arr){
long temp;
for(int i=0;i<arr.length-1;i++){
for(int j = arr.length-1;j>i;j--){
if(arr[j] < arr[j-1]){
temp = arr[j];
arr[j] = arr[j-1];
arr[j-1] = temp;
}
}
}
}
}
package ch02;
import ch01.MyArray;
public class TestBublleSort {
public static void main(String[] args) {
long[] arr = new long[3];
arr[0] = 99;
arr[1] = 33;
arr[2] = 55;
BublleSort.sort(arr);
System.out.print("{");
for(long num:arr){
System.out.print(num+" ");
}
System.out.println("}");
}
}