package practice.people.apple;标签:arr,Java,int,52,---,static,数组,public From: https://blog.51cto.com/u_15943742/6131370
//在数组中查找一个数,看是否存在,请返回值
public class FoundNumber {
public static void main(String[] args) {
//定义数组
int arr[] = {10,24,34,31,65,52,32,10};
//判断数是否在数组中存在
boolean temp = contains(arr,52);
System.out.println(temp);
}
public static boolean contains(int[] arr,int number) {
for(int i = 0;i < arr.length; i++) {
if(arr[i] == number)
return true;
}
return false;
}
}