主题:请问 String变量是否可以接受这个值
firstName 是 private String firstName;
firstName=fullName.substring(0,a);
编译的时候说有错误 unreachable statement
[b][size=4][color=FF0000]下面是代码请帮我看看,谢谢![/[/color][/size]b]
public class Name2
{
private String middleName;
private String firstName;
private String fullName;
private String lastName;
public Name2(String newFullName)
{
String newFirstName;
String newMiddleName;
String newLastName;
fullName=newFullName;
// firstName();
// middleName();
// lastName();
// newFullName =newFirstName+newMiddleName+newLastName;
}
public String firstName()
{
int a=fullName.indexOf(" ");
return fullName.substring(0,a);
firstName=fullName.substring(0,a);
}
public String middleName(String newMiddleName)
{
int a=fullName.lastIndexOf(" ");
int b=firstName.length();
return fullName.substring(b,a);
}
firstName=fullName.substring(0,a);
编译的时候说有错误 unreachable statement
[b][size=4][color=FF0000]下面是代码请帮我看看,谢谢![/[/color][/size]b]
public class Name2
{
private String middleName;
private String firstName;
private String fullName;
private String lastName;
public Name2(String newFullName)
{
String newFirstName;
String newMiddleName;
String newLastName;
fullName=newFullName;
// firstName();
// middleName();
// lastName();
// newFullName =newFirstName+newMiddleName+newLastName;
}
public String firstName()
{
int a=fullName.indexOf(" ");
return fullName.substring(0,a);
firstName=fullName.substring(0,a);
}
public String middleName(String newMiddleName)
{
int a=fullName.lastIndexOf(" ");
int b=firstName.length();
return fullName.substring(b,a);
}