- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSearch.java
More file actions
Latest commit
34 lines (34 loc) · 680 Bytes
/
Copy pathSearch.java
File metadata and controls
34 lines (34 loc) · 680 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
importjava.util.Scanner;
classSearch
{
publicbooleansearch(intarr[], intsearch_element)
{
intt=0;
for(inti=0;i<arr.length;i++)
{
if(arr[i]==search_element)
{
t=1;
break;
}
}
if(t==1) returntrue;
elsereturnfalse;
}
publicstaticvoidmain(Stringargs[])
{
Searchobj = newSearch();
Scannersc = newScanner(System.in);
intarr[] = newint[5];
for(inti=0;i<arr.length;i++)
{
arr[i] = sc.nextInt();
}
intsearch_element = sc.nextInt();
booleanres = obj.search(arr, search_element);
if(res == true)
System.out.println("Search element is found");
else
System.out.println("Search element is not found");
}
}