public class Main {
public static void main(String[] args) {
int[] arr = {90, 80, 70, 60, 50, 40, 1};
boolean bool;
for (int i = 0; i < arr.length; i++) {
bool = false;
for (int j = 0; j < arr.length - 1; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
bool = true;
}
}
if (bool == false) {
System.out.println("Sorted Array");
for (int a = 0; a < arr.length; a++) {
System.out.print("[" + arr[a] + "]");
}
break;
}
}
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: