-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
23 lines (22 loc) · 709 Bytes
/
Copy pathMain.java
File metadata and controls
23 lines (22 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Arrays;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
static void bubbleSort(int[] arr){
for(int i=0;i<arr.length;i++){
for(int j=1;j<arr.length-i;j++){
if(arr[j-1]>arr[j]){
int temp = arr[j-1];
arr[j-1] = arr[j];
arr[j] = temp;
}
}
}
}
public static void main(String[] args) {
int[]array = {5,3,2,1};
bubbleSort(array);
System.out.println(Arrays.toString(array));
System.out.println("hello world");
}
}