本帖最后由 言钟钟 于 2014-9-5 10:52 编辑
package person;
class Name
{
private String firstName;
private String lastName;
public Name(){}
public Name(String firstName,String lastName)
{
this.firstName = firstName;
this.firstName = lastName;
}
public String getFirstName()
{
return firstName;
}
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
public String getLastName()
{
return lastName;
}
public void setLastName(String lastName)
{
this.lastName = lastName;
}
}
public class Person
{
private final Name name;
public Person(Name name)
{
this.name =name;
}
public Name getName()
{
return name;
}
public static void main(String[] args)
{
Name n = new Name("哈利","波特");
Person p = new Person(n);
System.out.println(p.getName().getFirstName());
}
}
求求各位大神看看哪里出错了?
|
|