// write a bubble sort code in java using function import java.util.Scanner; public class BubbleSort{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println("Enter the number of elements in the array"); int n = sc.nextInt(); int[] arr = new int[n]; System.out.println("Enter the elements of the array"); for(int i=0;iarr[j+1]){ int temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } // print the array after each iteration for better understanding printArray(arr); // print the values of i and j for better understanding System.out.println(" for i = "+i+" j = "+j); } } } }