Field
A data member of a class. Unless specified otherwise, a field is not static.
类的数据成员。除非指定,它不是静态的。
举例:
public class Customer {
// Fields of Customer
final String field1 = "Fixed Value";
int name;
}
Attribute
An attribute is another term for a field. It’s typically a public field that can be accessed directly.
Field 的别称,它通常是可以直接访问的 public field,例如数组的长度。(Java SE 术语表中无此定义)
Property
Characteristics of an object that users can set, such as the color of a window.
对象的特征,用户可以设置它,例如窗户的颜色。
举例:
public class Window {
// Property of Window
private String color;
public String getColor()
{
return this.color;
}
public void setColor(String color)
{
this.color = color;
}
}
References
- What is the difference between field, variable, attribute, and property in Java
- What is the difference between field, variable, attribute, and property in Java POJOs?
- Glossary of Terms
如有问题请在下方留言,文章转载请注明出处,详细交流请加下方群组!请大佬不要屏蔽文中广告,因为它将帮我分担服务器开支,如果能帮忙点击我将万分感谢。