-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaThread.java
More file actions
51 lines (37 loc) · 1.09 KB
/
JavaThread.java
File metadata and controls
51 lines (37 loc) · 1.09 KB
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
import java.util.Random;
import java.util.Arrays;
import java.util.Scanner;
public class JavaThread
{
public static void main(String args[])
{
int[] ar1 ;
ar1 = new int[20];
//int i ;
for(int i = 0; i< ar1.length ; i++)
{
ar1[i] = (int)(Math.random() * 100);
System.out.println(ar1[i]+ " " );
}
Arrays.sort(ar1);
//for(int j = 0; j< ar1.length ; j++)
System.out.println("SOrted Array :" );
for(int j = 0; j< ar1.length ; j++)
{
//System.out.println("SOrted Array :" );
// ar1[i] = (int)(Math.random() * 100);
System.out.println(ar1[j]+ " " );
}
Scanner in = new Scanner(System.in);
System.out.println("Enter the number to search")
d = in.nextInt() ;
for(int j = 0; j< ar1.length ; j++)
{
//System.out.println("SOrted Array :" );
// ar1[i] = (int)(Math.random() * 100);
if(ar1[i] == d) {
System.out.println("Found "+ d );
}
}
}
}