获取索引位置
package demo4; public class Demo9 { public static void main(String[] args) { // TODO Auto-generated method stub //获取第一次出现的索引 // String str ="We are the world"; // int index = str.indexOf("e"); // int index1 = str.indexOf("e",3); // System.out.println(index); // System.out.println(index1); //获取倒数第一次出现的索引 String str ="Let it go! Let it go!"; int lastindex = str.lastIndexOf("t"); int lastindex1 = str.lastIndexOf("t",14); System.out.println(lastindex); System.out.println(lastindex1); } }