String[] str={"数学","语文","英语","物理","化学","生物"};
System.out.print("地理");
如何判断“地理”这个字符串是否在 str[] 这个数组中?
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] strs={"数学","语文","英语","物理","化学","生物"};
for(String str:strs)
{
if(str.indexOf("地理")>0){
System.out.println("找到了");
break;
}
}
System.out.println("没有找到");
}
}