判断一个字符串是否在一个字符串数组中



public class shuzuhe {


public static void main(String[] args) {
// TODO Auto-generated method stub
     String []score={"a","abc","a"};//记得加引号
     String chuan="a";
     int b=0;
      for(int i=0;i    
    if(chuan==score[i]){
    b=1;
    break;    //记得break,直接跳出循环
         }
   
      }
    if(b==1){
       System.out.print("存在");
      }
        else if(b!=1)
        System.out.print("不存在");



}

你可能感兴趣的:(java学习)