再会,
我是 JAVA 的新手,正在学习这门语言,我所学到的似乎是一门很棒的语言。我的问题与以下有关:
假设我有这样的课程:
public class Person{
private String firstName;
private String lastName;
private int age;
private String entireName;
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 int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getEntireName() {
return entireName;
}
public void setEntireName(String entireName) {
this.entireName = entireName;
}
public static void Main(String args[]){
Person person = new Person();
person.setFirstName("Jhon");
person.setLastName("Adams");
person.setAge(20);
//Atention this line
person.setEntireName(person.getFirstName()+person.getLastName());
}
}
该语言允许我这样做:person.setEntireName(person.getFirstName()+person.getLastName());
它工作得很好但是我想知道如何最好地做到这一点,它在对象级别的行为以及性能有多高或多低。
谢谢 ..