0
An example of bubble sorting in arrats in java
plz give a complete program of bubble sorting in array. I want to understand it deeply by an example.
1 Odpowiedź
+ 10
int[] arr = {2, 3, 4, 1, 5};
for (int i = 0; i < arr.length; i++)
for (int j = 0; j < arr.length - 1 - i; j++)
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
for (int i : arr)
System.out.println(i);