-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewFile.java
More file actions
35 lines (30 loc) · 943 Bytes
/
Copy pathnewFile.java
File metadata and controls
35 lines (30 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.*;
public class newFile {
public static void main(String[] args) {
int[] array;
array = new int[10];
Scanner sc = new Scanner(System.in);
System.out.println("Enter your array");
for (int i = 0; i <= 9; i++) {
array[i] = sc.nextInt();
}
sc.close();
System.out.println("Your array is : ");
for (int i = 0; i < array.length; i++) {
System.out.print(array[i]);
}
System.out.println();
for (int i = 0; i < array.length; i++) {
for (int j = i + 1; j < array.length; j++) {
if (array[i] > array[j]) {
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + ", ");
}
}
}