public class strMethods {
public static void main(String[] args) {
//获取字符串中特定字符串的位置
String s = "hello Word!";
//indexof:查找某个特定字符串在整个字符串中第一次出现的位置
//字符窜下标从0开始
int index = s.indexOf("o");
System.out.println(index);
//查找不到位置 要返回-1
int index2 = s.indexOf("yes");
System.out.println(index2);
//lastIndexof:查找某个特定字符串在整个字符串中最后一次出现的位置
int index3 = s.lastIndexOf("o");
System.out.println(index3);
//截取特定字符串内容
//substring(index);从index位置(包含)开始截取,一直截取到字符串末尾
String result =s.substring(4);
System.out.println(result);
//substring(index1,index2);从index1位置(包含)开始截取截取到index2位置(不包含inedx2)的字符串
String result2 = s.substring(4,8);
System.out.println(result2);
/*截取大玉儿
String word = "Hello, “;
word = word.trim();
String s = word.concat("小鱼儿");
int indrx1 = s.indexof(',');
int indrx2 = s.indexof('!');
System.out.println(s.substring(index1+1,index2));
*/
}
}