JAVA---线性查找
package lll;
public class Test {
public static void main(String[] args) {
String[] str=new String[]{"aa","bb","cc","dd","ee"};
//要查找的字符串dest
String dest="cc";
boolean isFlag=true;
for(int i=0;i<str.length;i++){
if(dest.equals(str[i])){
System.out.println("找到了!位置是"+i);
isFlag=false;
break;
}
}
if(isFlag){
System.out.println("抱歉,没有找到!");
}
}
}