1 ~ 写在前面:
很多时候用过的东西不温习就忘记了,到时候需要的时候还是需要百度,温故而知新,说的真好!!
2~进入主题
Java判断String是否以某个字符串开头:
语法:
startWith(String prefix, int toffset)
prefix:指定的前缀
toffset:在字符串中查找的位置,可以省略,省略就从第一个下标开始查找
String strTest= "helloWord";
System.out.println(strTest.startsWith("hello"));//输出true
System.out.println(mobile.startsWith("helloY"));//输出false
System.out.println(mobile.startsWith("hello",4));//输出false
Java判断String是否以某个字符串结尾:
endWith(String prefix, int toffset)
String strTest= "helloWord";
System.out.println(strTest.cc("Word"));//输出true
System.out.println(strTest.endsWith("words"));//输出false

2055

被折叠的 条评论
为什么被折叠?



