Skip to content

Instantly share code, notes, and snippets.

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 mahmmoudkinawy/c211c2198f034d774b6dbd533c32d814 to your computer and use it in GitHub Desktop.
Save mahmmoudkinawy/c211c2198f034d774b6dbd533c32d814 to your computer and use it in GitHub Desktop.
Mahmmoud Hisham's Task
Scanner scan = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<>();
System.out.print("Enter Number of records you wanna add to ArrayList: ");
int num = scan.nextInt();
for (int i = 0; i < num; i++)
list.add(scan.nextInt());
System.out.print("Enter Number to search is exist or not :");
int n = scan.nextInt();
System.err.println(list.contains(n) ? "Found" : "Not Found");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment