Skip to content

Instantly share code, notes, and snippets.

Created April 4, 2014 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9979510 to your computer and use it in GitHub Desktop.
Save anonymous/9979510 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class tesstt {
public static void main (String args []) {
System.out.print("Array: ");
int [] arr = new int[9];
for (int i = 0; i < arr.length; i++) {
arr[i] = (int) (1 + (Math.random() * 50));
System.out.print(" " + arr[i]);
}
System.out.print("\nValue to find: ");
Scanner s = new Scanner(System.in);
int find = s.nextInt();
for (int i = 0; i < arr.length; i++) {
if (arr[i] == find) {
System.out.print(find + " is in the array.\n");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment