<分区>
我写了一段代码,在名称字符串中分隔名字和姓氏:
public class NameSeperator {
public static void main(String[] args)
{
String custName="Your Name";
int index;
String firstName;
index=custName.indexOf(" ");
**int last=custName.lastIndexOf("")**;
firstName=custName.substring(0,index);
String lastName=custName.substring(index+1,last);
// get the first name
System.out.println("First Name = "+firstName);
System.out.println("Last Name = "+lastName);
}
}
我用过
int last=custName.lastIndexOf("")
这里只用了“”,但这里取的是完整的字符串。“”是指调用特定字符串方法的完整字符串吗?