String fileName = "aaaa";
int i = fileName.lastIndexOf("\\");
System.out.println(i);
上面代码输出结果为-1
/**
* @return the index of the last occurrence of
* the specified substring,or {@code -1}
* if there is no such occurrence.
* 翻译:指定字符串最后一次出现的索引
* 或没有发生返回-1
*/
public int lastIndexOf(String str) {
return lastIndexOf(str, value.length);
}