Advertisement
kamandos

HW1

Jun 29th, 2022
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. class Main {
  4.   public static void main(String[] args) {
  5.  
  6.     int[] num = {1, 2, 3, 4, 5};
  7.     int toFind = 3;
  8.     boolean found = false;
  9.  
  10.     for (int n : num) {
  11.       if (n == toFind) {
  12.         found = true;
  13.         break;
  14.       }
  15.     }
  16.    
  17.     if(found)
  18.       System.out.println(toFind + " is found.");
  19.     else
  20.       System.out.println(toFind + " is not found.");
  21.  
  22.   }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement