最近常遇到如下的描述,希望高手能为我解答
when you creat a package-access class, it still make sense to make the field of the class private创建宝访问权限类时,仍然要将类的字段名设为private才有意义。请问:“类的字段名是何物(the field of the class)”因为类的封装只有包何public,所以这个类的字段肯定不是类名,那又是什么呢?类的方法,类的成员?
when you creat a package-access class, it still make sense to make the field of the class private创建宝访问权限类时,仍然要将类的字段名设为private才有意义。请问:“类的字段名是何物(the field of the class)”因为类的封装只有包何public,所以这个类的字段肯定不是类名,那又是什么呢?类的方法,类的成员?
public class Employee {
private String name;//filed
private int age;//filed public String getName(){...}
...
}
Name和age是类的字段?
这里的field相当于property的意思,不要太拘泥于英文单词