- contains indexOf, lastIndexOf,startsWith,endWith
public class HelloWorld {
public static void main(String args[]){// String args[]字符串数组的意思
String str = "www.mldn.cn";
System.out.println(str.contains("mldn"));//true
System.out.println(str.indexOf("mldn"));//4
System.out.println(str.indexOf("hello"));//-1
System.out.println(str.lastIndexOf("."));//8
System.out.println(str.lastIndexOf(".",5));//3,从第5个开始查;
System.out.println("---------------");
String str2 = "**@@www.mldn.cn##";
System.out.println(str2.startsWith("**"));//true
System.out.println(str2.startsWith("**",2));// false ,从第2个开始判断;
System.out.println(str2.endsWith("##"));//true
}
}
标签:mldn,7.12,System,String,println,查找,str,字符串,out
From: https://www.cnblogs.com/pansidong/p/17461976.html