Having said that, the remainder of this tutorial uses the following general guidelines when discussing fields and variables. If we are talking about "fields in general" (excluding local variables and parameters), we may simply say "fields". If the discussion applies to "all of the above", we may simply say "variables". If the context calls for a distinction, we will use specific terms (static field, local variables, etc.) as appropriate. You may also occasionally see the term "member" used as well. A type's fields, methods, and nested types are collectively called its members.
 
先说一下 field 和 variable 之间的区别:
class variables and instance variables are fields while local variables and parameter variables are not. All fields are variables.
成员变量(field)是指类的数据成员,而方法内部的局部变量(local variable)、参数变量(parameter variable)不能称作 field。field 属于 variable,也就是说 variable 的范围更大。
术语解释:
域或字段、实例变量、成员变量(field, instance variable, member variable, non-static field)
field: A data member of a class. Unless specified otherwise, a field is not static.
非 static 修饰的变量。
虽然有如上定义,但是一般在使用时,成员变量(field)包括 instance variable 和 class variable。为了区分,个人认为,用实例变量/非静态变量(instance variable / non-static field)描述上面的定义更佳。
成员变量与特定的对象相关联,只能通过对象(new 出)访问。
声明在类中,但不在方法或构造方法中。
如果有多个对象的实例,则每一个实例都会持有一份成员变量,实例之间不共享成员变量的数据。
作用域比静态变量小,可以在类中或者非静态方法中使用以及通过生成实例对象使用。(访问限制则不可用)
JVM 在初始化类的时候会给成员变量赋初始值。
Example:
类字段、静态字段、静态变量(class variable, static field, staic variable)
使用 static 修饰的字段,一般叫做静态变量。
声明在类中,但不在方法或构造方法中。
多个实例对象共享一份静态变量
JVM在准备类的时候会给静态变量赋初始值。
作用域最大,类中都可以访问,或通过 类名.变量名 的方式调用(访问限制则不可用)。
Example:
局部变量(local variable)
定义在一个区块内(通常会用大括号包裹),区块外部无法使用的变量。
定义在一个区块内(通常会用大括号包裹),没有访问修饰符,区块外部无法使用的变量。
没有默认值,所以必须赋初始值
生命周期即为方法的生命周期
Example:
参数(input parameter, parameter (variable), argument)
这个就不多说了,要注意的是 argument 和 parameter 的区别(下文)。
另外,Oracle 官方文档中将参数分为了构造参数、方法参数和异常参数三部分。
Example:
Strictly speaking, a parameter is a variable within the definition of a method. An argument would be the data or actual value which is passed to the method. An example of parameter usage: int numberAdder(first, second) An example of argument usage: numberAdder(4,2)
不可变量、常量(final variable, constant)
即为使用 final 关键词修饰的变量。不可变量属于成员变量。
成员(member)
A field or method of a class. Unless specified otherwise, a member is not static.
指的是类中非静态的成员变量或方法。(用法同field)
属性(property)
Characteristics of an object that users can set, such as the color of a window.
可以被用户设置或获取的对象特征即为属性。
POJO 或 JavaBean 中的成员变量也称作属性(具有set、getter方法)。
最后,总结一下国内目前的惯用法(英文取其一,序号对应上文):
field -> 成员变量, instance variable / non-static field -> 实例变量/非静态变量
class variable -> 静态变量
local variable -> 本地变量
input parameter -> 参数
final variable -> 常量
member -> 成员(用法同field)
property -> 属性返回搜狐,查看更多

【java】 field 和 variable 区别及相关术语解释的更多相关文章

  1. 【SSO单点系列】(6):CAS4.0 单点流程序列图(中文版)以及相关术语解释(TGT、ST、PGT、PT、PGTIOU)

    CAS 相关的内容好久没写了,可能下周会继续更新一些内容吧. 在上一篇中的单点流程序列图由于是从官网直接下载来的,上面都是英文,可能有的朋友看不懂,因此修改成中文的. PS:只修改了一个,第二个图明天 ...

  2. java field, property,variable及getField和getDeclaredField的区别

    java 里面的field ,property, attribute,variable的区别 field: 就是定义的用于保存数据的字段 property: property是用于描述类中的特征,所以 ...

  3. Java 并发,相关术语

    Java 并发,相关术语: 术语 作用 synchronize 可修饰方法.代码块.类:介绍:https://www.cnblogs.com/zyxiaohuihui/p/9096882.html L ...

  4. Java和C++的区别

    这是一个Java语言和C++语言之间的比较. 目录 [隐藏]  1 设计目标 2 语言特性 2.1 语法 2.2 语义 2.3 资源管理 2.4 库 2.5 运行时 2.6 模板 vs. 泛型 2.7 ...

  5. 前端入门7-JavaScript语法之相关术语

    声明 本系列文章内容全部梳理自以下几个来源: <JavaScript权威指南> MDN web docs Github:smyhvae/web Github:goddyZhao/Trans ...

  6. Spring的AOP开发的相关术语

    转载自 https://www.cnblogs.com/ltfxy/p/9873618.html SpringAOP简介: AOP思想最早是由AOP联盟组织提出的.Spring使用这种思想最好的框架. ...

  7. Spring框架学习05——AOP相关术语详解

    1.Spring AOP 的基本概述 AOP(Aspect Oriented Programing)面向切面编程,AOP采取横向抽取机制,取代了传统纵向继承体系重复性代码(性能监视.事务管理.安全检查 ...

  8. Dalvik VM (DVM) 与Java VM (JVM) 的区别?

    Dalvik虚拟机存在于Android系统,JVM是java虚拟机,两者都是虚拟机,本文就对两者进行比较,讲述它们的不同. Dalvik虚拟机是Google等厂商合作开发的Android移动设备平台的 ...

  9. Spring AOP相关术语

    ---------------------siwuxie095                                 Spring AOP 相关术语         (1)Joinpoint ...

随机推荐

  1. Markdown - 如何使用上标、下标

    解决方法 Markdown可以和HTML的语法兼容,可以通过HTML的上标和下标标签来实现效果: 标签 写法 效果 上标 2<sup>10</sup> 210 下标 H< ...

  2. 序列化 jprotobuf

    jprotobuf工作原理如下: 扫描类上的注解的信息,进行分析(与protobuf读取proto文件进行分析过程相似) 根据注解分析的结果,动态生成java代码进行protobuf序列化与反序列化的 ...

  3. PAT甲级——1135 Is It A Red-Black Tree (30 分)

    我先在CSDN上面发表了同样的文章,见https://blog.csdn.net/weixin_44385565/article/details/88863693 排版比博客园要好一些.. 1135 ...

  4. bootstrapValidator 常用的验证

    $("#表单ID").bootstrapValidator({ message: 'This value is not valid', excluded: [':disabled' ...

  5. Nodejs 文件修改自动重启扩展

    使用 supervisor: 安装: # 全局安装 npm -g install supervisor 启动: supervisor app.js

  6. javaScript面向对像

    1.创建对象 <script type="text/javascript"> function Flower(name,addre) { this.name=name; ...

  7. 一步步实现自己的ORM(五)

    上一张优化了ORM的INSERT.UPDATE.DELETE,但将数据库里的值填充到实体类这块还没优化.另外有博友在网上咨询说你这个都是查询所有字段的,而他的需求是按需查询字段,不是一次性取出来所有字 ...

  8. debian使用apt安装时出现“更换介质,插入驱动器"/media/chrom/"再按回车键”的提示,无法从网络安装,解决?

    原文链接:https://www.zhihu.com/question/22132663 nano /etc/apt/sources.list把那出现的那行注释掉:含CD盘的一行:然后apt-get ...

  9. 随机不重复的取数组元素,并赋值给div使用

    function pos(){ var items = $('.starone'); items.each(function () { var rand = getRandom(); $(this). ...

  10. CF1066E Binary Numbers AND Sum

    思路: 模拟.实现: #include <iostream> using namespace std; ; ], b[]; ]; int main() { int n, m; while ...