-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArraySort.java
43 lines (36 loc) · 1.14 KB
/
ArraySort.java
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
36
37
38
39
40
41
42
43
import java.util.Arrays;
import java.util.Scanner;
public class ArraySort {
// public static int[] arraySort(int ar[]){
// int temp;
// for(int i = 0;i<ar.length;i++){
// for(int j =i+1;j<ar.length;j++){
// if(ar[j]<ar[i])
// {
// temp = ar[j];
// ar[j]=ar[i];
// ar[i]=temp;
// }
// }
// }
// return ar;
// }
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Size of Array: ");
int len = sc.nextInt();
int ar[] = new int[len];
for(int i =0;i<len;i++){
System.out.print("Enter Element "+(i+1)+" : ");
ar[i]=sc.nextInt();
}
sc.close();
// ar = arraySort(ar);
// for(int a :ar){
// System.out.print(a+" , ");
// }
/* Website Logic : It is amazing..!! */
Arrays.sort(ar);
System.out.println(Arrays.toString(ar));
}
}