#Fields are also called member variables, which reflect the state of the class, and changes in the state are implemented by methods in the class body.
Domains are member variables in a class, sometimes also called fields, and attributes all have the same meaning. A public domain is a domain that can be directly accessed in other classes, that is, it has a domain. For example:
class Test { private int a; // 这是一个私有域,只能在本类访问 public int b; // 这就是一个公有域了,可以在其它类中直接访问 // 这是保护域,这类域可以在本类及其子类,还有与在本类所在同一包下的其类 // 中直接访问 protected int c; }
Definition of domain: Define static properties of the class.
Fields must be defined directly in the class body and cannot be included in method definitions.
The format of domain definition is as follows:
[Modifier] Type name Domain name;
Note: The modifier part is optional and can be One or more combinations of the keywords public, protected, private, final, static, transient and volatile;
For more java knowledge, please pay attention to the java basic tutorial column.
The above is the detailed content of What is a domain in java. For more information, please follow other related articles on the PHP Chinese website!