package test;
public class Test {
public static void main(String[] args) {
String str = "ab";
System.out.println(isStr(str).toString());
}
/**
* 判断一个字符串数组中包含某个字符或字符串:返回一个boolean:参数判断的字符
* 1.定义一个字符串数组
* 2.遍历这个数组
* 3.判断要指定的字符串是否包含在字符串数组内
* 4.如果包含返回true,否则返回false
*/
public static Boolean isStr(String str){
String array[] = {"a","b","c","hello"};
for(int i = 0;i<array.length;i++){
if(str.equals(array[i])){
return true;
}
}
return false;
}
}