public class Test
{
public static void main(String[] args)
{
String str="We are students";
int size=str.lastIndexOf("");
System.out.println("空字符在字符串str中的索引位置是:"+size);
System.out.println("字符串str的长度是:"+str.length());
}
}
/*如果lastIndexOf()方法中的参数是空字符串“”,则返回的结果与调用该字符串length()方法
的返回结果相同。
*/