日期:2014-05-20 浏览次数:20871 次
int number = 0; Integer[] numbers = new Integer[]{1, 2, 3, 4, 0}; System.out.println(Arrays.asList(numbers).contains(number));
------解决方案--------------------
int number=0;
int[] numbers=new numbers[]{1,2,3,4,0};
boolean temp = false;
//此循环表示数组numbers是否有等于number的值,若有将布尔型temp等于true。否则还为false.
for(int i=0;i<numbers.length;i++){
if(number==numbers[i]){
temp = true;
}
}
//若为true输出你想要的,反之亦然
if(temp==true){
System.out.println();
}else{
System.out.println();
}