以下是 Java 语言实现冒泡排序的示例代码:
public class BubbleSort {
public static void main(String[] args) {
int[] arr = {
5, 2, 8, 3, 9, 1};
bubbleSort(arr);
System.out.println(Arrays.toString(arr));
}
public static void bubbleSort(int[] arr) {
int n = arr.len