-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patharrayexample.java
More file actions
51 lines (30 loc) · 821 Bytes
/
arrayexample.java
File metadata and controls
51 lines (30 loc) · 821 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//program of sorting the arrays
import java.util.Arrays;
import java.util.Scanner;
public class arrayexample {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//One dimensional array
int b[] = {1,2,3,4,5};
int a[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
for(int i =0; i<a.length; i++)
{
System.out.print(a[i]+" ");
}
System.out.println("");
Arrays.sort(a);
for(int i =0; i<a.length; i++)
{
System.out.print(a[i]+" ");
}
System.out.println();
System.out.println(Arrays.asList(a));
System.out.println(Arrays.binarySearch(a, 3));
System.out.println();
Arrays.toString(a);
for(int i =0; i<a.length; i++)
{
System.out.print(a[i]+" ");
}
}
}