Home > Java > JavaBase > What is a domain in java

What is a domain in java

Release: 2019-12-26 11:37:16
Original
3654 people have browsed it

What is a domain in java

#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;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template