java中变量的几种名称fileds,parameters,arguments

本文详细介绍了Java中的不同类型的变量,包括字段、参数、本地变量及它们的区别,并解释了参数与实参的关系。

java中的变量有好几种类型(此处的类型不是指type,基础类型或者某个java对象),可以根据变量的声明位置和变量的出现时间分类,以下英文摘自oracle的官方JDK tutorial。使用单词可以更清晰的理解变量。

There are several kinds of variables:

Member variables in a class—these are called fields.
Variables in a method or block of code—these are called local variables.
Variables in method declarations—these are called parameters.

Note: Parameters refers to the list of variables in a method declaration. Arguments are the actual values that are passed in when the method is invoked. When you invoke a method, the arguments used must match the declaration’s parameters in type and order.

java中变量(variables)按照其声明的位置可以分为以下几种:
1、fields. 字段。声明在类里面。
2、parameters 参数。声明在方法或者构造器的()里。
3、local variables 本地变量。 声明在方法体里或者构造器里。
以上都是静态变量的名称。

arguments:(英文解释中不是argument的复数)
是java在runtime的时候,JVM调用方法或者构造器时传入的参数。

在 IT 领域,“Fields”常见的含义及相关信息如下: ### 数据库领域 在数据库中,“Fields”指的是字段。字段是数据库表中的列,用于存储特定类型的数据。例如,在一个存储员工信息的数据库表中,可能有“员工姓名”“员工编号”“部门”等字段。每个字段都有其特定的数据类型,如文本型、数值型、日期型等。 ```sql -- 创建一个包含字段的表 CREATE TABLE employees ( employee_id INT, employee_name VARCHAR(50), department VARCHAR(30), hire_date DATE ); ``` ### 编程领域 在编程语言里,“Fields”也可表示类的成员变量。成员变量是类的属性,用于存储对象的状态信息。以 Java 语言为例: ```java class Employee { // 定义类的字段 private int employeeId; private String employeeName; // 构造函数 public Employee(int id, String name) { this.employeeId = id; this.employeeName = name; } // Getter 方法 public int getEmployeeId() { return employeeId; } public String getEmployeeName() { return employeeName; } } ``` ### 表单设计领域 在网页或应用程序的表单设计中,“Fields”表示表单字段。用户可以在这些字段中输入信息,如用户名、密码、电子邮件地址等。例如,使用 HTML 设计一个简单的登录表单: ```html <!DOCTYPE html> <html> <body> <form action="/login" method="post"> <label for="username">用户名:</label><br> <input type="text" id="username" name="username"><br> <label for="password">密码:</label><br> <input type="password" id="password" name="password"><br><br> <input type="submit" value="登录"> </form> </body> </html> ```
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值