Linear Searching double Arrays in Java
Description
The following code shows how to linear Searching double Arrays.
Example
//w w w.j a v a 2s .com
public class Main {
public static void main(String[] args) {
double[] x = { 92.3, 45.2, 6.8, -3.6, 10, 9000, -39 };
int i;
for (i = 0; i < x.length; i++)
if (x[i] == 9000)
break;
if (i == x.length)
System.out.println("Not found");
else
System.out.println("Found");
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »