public class bubbleSort { private static final int max = 10; public static void main(String[] args){ int[] array = new int[max]; System.out.println("The array to be sorted is"); for(int i = 0; i < max; i++){ array[i] = (int) (Math.random()*100); System.out.print(" | " + array[i]); } System.out.println(" | "); //The algorithm for(int i = 0; i < 9; i++){ for(int j = 0; j < 9; j++){ if(array[j] > array[j+1]){ int temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; } } } System.out.println("The sorted array is"); for(int i = 0; i < max; i++){ System.out.print(" | " + array[i]); } System.out.println(" | "); } }