/*这是一个静态函数,不用声明对象就可以用的,如你的类名为Test,在任何情况下都可以调用Test.isHave函数*/ 

public static boolean isHave(String[] strs,String s){ 

/*此方法有两个参数,第一个是要查找的字符串数组,第二个是要查找的字符或字符串*/
  int i = str.length;
        while (i-- > 0){
            if(str[i] == a){
                return true;
            }
        }
        return false;
} 
public static void main(String[] args){ 

    String[] strs={"aaa","bbbb","cccc","dddd"};//定义字符串数组 

    if(isHave(strs,"aaaa")){//调用自己定义的函数isHave,如果包含则返回true,否则返回false 
       System.out.println("包含");//打印结果 
    }else{ 
       System.out.println("不包含");//打印结果 
    } 
} 


相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2021-09-12
  • 2021-08-21
  • 2021-11-17
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2021-11-17
  • 2022-12-23
  • 2022-02-13
  • 2021-09-23
相关资源
相似解决方案