-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraySearching.java
More file actions
35 lines (26 loc) · 870 Bytes
/
Copy pathArraySearching.java
File metadata and controls
35 lines (26 loc) · 870 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.Scanner;
public class ArraySearching {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] arr = {3,1,4,5,45,48,4,44,444,5,56,98,89898,78};
System.out.println("Welcome to Array Searching\n");
System.out.print("Please Enter the number you want to search: ");
int num = input.nextInt();
boolean iFind = isFound(arr,num);
if (iFind){
System.out.println("Your number is present in Array List");
}else{
System.out.println("Your number is not present in Array List");
}
}
public static boolean isFound(int[] arr, int num) {
int i = 0;
while(i < arr.length){
if (arr[i] == num) {
return true;
}
i++;
}
return false;
}
}