第一题:
package test;
public class selectArray {
public static void main(String[] args) {
getSelectArray(11);
}
public static void getSelectArray(int num){
int array[] = {11,13,15,16,45};
int index = -1;
for(int i = 0; i < array.length; i++){
if(array[i] == num ){
index = i;
}
}
if( index != -1 ){
System.out.println("数组中有该数,下标为"+index);
}else{
System.out.println("数组中不存在该数");
}
}
}
温馨提示:答案为网友推荐,仅供参考