forked from badal74/java-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion60.java
More file actions
15 lines (15 loc) · 525 Bytes
/
Copy pathQuestion60.java
File metadata and controls
15 lines (15 loc) · 525 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class Question60{
public static int linearSearch(int[] arr, int key){
for(int i=0;i<arr.length;i++){
if(arr[i] == key){
return i;
}
}
return -1;
}
public static void main(String a[]){
int[] a1= {10,20,30,50,70,90};
int key = 50;
System.out.println(key+" is found at index: "+linearSearch(a1, key));
}
}