public class Driver { public static void main(String [] args) { System.out.println("Random Array"); IntArray myArray = new IntArray(100, 100); myArray.print(); myArray.sortBubbleStyle(); myArray.print(); /* System.out.println("Bubble Sort"); int [] arr = {6,3,8,2,0,1,4,9,7,5}; printArray(arr); int [] sorted = bubbleSort(arr); printArray(sorted); */ } public static void printArray(int [] arr) { for(int i:arr) System.out.print(i + ", "); System.out.println(""); } public static int[] bubbleSort(int [] input) { int n = input.length; boolean swapped; do { swapped = false; for(int i=1; i < n; i++) { if(input[i-1] > input[i]) { //swap int tmp = input[i-1]; input[i-1] = input[i]; input[i] = tmp; swapped = true; } } } while(swapped); return input; } }