Can the terms’ variable ‘and’ field ‘be used interchangeably in Java?

When learning java with several books, no one seems to be able to say when to use which term

Variables are defined in methods, and fields are part of classes

Solution

Edit:

You have the right idea

After returning to the Java documentation, I will use their terminology:

>Member variables in the class – these variables are called fields. > Variables in methods or code blocks – these variables are called local variables. > Variables in method declarations – these variables are called parameters

Variables refer to fields, local variables, and parameters

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>