public class ImoocStudent {
public boolean contains(int[] arr,int element){
boolean result = false;
for(int value : arr){
if(value == element){
result = true;
break;
}
}
return result;
}
public static void main(String[] args){
ImoocStudent lei = new ImoocStudent();
int[] intArr = {1,3,5,7,9,11};
int element = 10;
boolean contains = lei.contains(intArr,element);
if(contains){
System.out.println("数组intArr中包含" + element);
} else {
System.out.println("数组intArr中不包含" + element);
}
}
}
标签:intArr,contains,int,元素,element,查找,result,数组,public
From: https://www.cnblogs.com/pansidong/p/17416927.html