// Sort an array using Bubble Sort // Last elements in the array are sorted first public class BubbleSort_v2 { public static void printArray(int[] a) { System.out.print("\nIndex i: "); for(int i=0; i< a.length; i++) System.out.printf("%2d, ", i); System.out.print("\nElement a[i]: "); for(int i=0; i< a.length; i++) System.out.printf("%2d, ", a[i]); System.out.println("\n\n"); } public static void main(String[] args) { int[] a= { 23, 78, 45, 8, 32, 56}; boolean DEBUG=true; // Print the unsorted array System.out.println("===== UNSORTED ARRAY ======"); printArray(a); // Sort the array using Bubble Sort // Last elements in the array are sorted first for(int i=0; i < a.length; i++) { for(int j=0; j