Home > Java > Javagetting Started > body text

Similarities and differences between member variables and local variables

王林
Release: 2020-06-08 16:58:57
forward
2435 people have browsed it

Similarities and differences between member variables and local variables

Similarities and differences between member variables and local variables:

Same points:

1. The format of defining variables is the same;

数据类型 变量名 = 变量值
Copy after login

(Video tutorial recommendation: java video tutorial)

2. They are declared first and then used;

3. Both have their corresponding scopes;

Differences:

1. The difference in the position of declaration between the two in the class;

Member variables are directly defined within a pair of { } in the class;

Local variables are declared within methods, method parameters, code blocks, constructor parameters, and inside constructors.

2. Local variables have no default initialization value.

Recommended tutorial: java entry program

The above is the detailed content of Similarities and differences between member variables and local variables. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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