Advertisement
Timur69

Array

Apr 2nd, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. package Tasks2;
  2.  
  3. import java.util.Arrays;
  4.  
  5. public class ArrayInt {
  6.     public static void main(String[] args) {
  7.         int[] arr = {2, 4, 5, 6, 8};
  8.         System.out.println(array(arr, 7));
  9.     }
  10.  
  11.     public static boolean array(int[] arr, int a) {
  12.         for (int i = 0; i < arr.length; i++) {
  13.             if (a == arr[i]) {
  14.                 return true;
  15.             }
  16.         }
  17.         return false;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement