1. 程式人生 > >【java】java判斷字串A中是否包含字串B

【java】java判斷字串A中是否包含字串B

public static void main(String[] args)
 {

  String str="ABC_001";
  if(str.indexOf("ABC")!=-1){
   System.out.println("包含");
  }else{
   System.out.println("不包含");
  }
 }