The content of the class body is divided into variable declaration and method definition. The variables declared in the variable declaration part are called member variables or domain variables.
The type of member variables can be any data type in Java, including basic types: integer, floating point, character, and logical types; reference types: arrays, objects, and interfaces.
Member variables are valid within the entire class, and their validity has nothing to do with the order in which they are written in the class body. However, it is not recommended to write the declaration of member variables dispersedly between methods. People are accustomed to introducing attributes first and then introducing behaviors.
For example:
classFactory{floata[];Workmanzhang;}
The member variable a of the Factory class is a float type array, and zhang is a variable declared by the Workman class, that is, an object.