given an array of int is there a way to do membership test to see if a particular number is present in the int array. the question was to do find missing number between 1-10 given by user. eg [1,2,3,4,5] if 1 is in array it should give true. I cant seem to post my code here.
import java.util.Scanner;
import java.util.Arrays;
public class Q1 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter numbers of element: ");
int size = scan.nextInt();
int arry[]=new int[size];
for(int i =0;i<size;i++){
System.out.println("Enter any number betweent 1-10:");
int element = scan.nextInt();
arry[i] = element;
}
System.out.println(Arrays.toString(arry));
System.out.println(Arrays.asList(arry).contains(1));
}
}