distinguish between variable and field
来源:互联网 发布:单元刚度矩阵 编辑:程序博客网 时间:2024/06/10 19:39
The important thing to remember is that parameters are always classified as "variables" not "fields". This applies to other parameter-accepting constructs as well (such as constructors and exception handlers) that you'll learn about later in the tutorial.
If we are talking about "fields in general" (excluding local variables and parameters), we may simply say "fields"
-----------------------------------------------------------------------------------------------------------------------
The Java programming language defines the following kinds of variables:
- Instance Variables (Non-Static Fields) Technically speaking, objects store their individual states in "non-static fields", that is, fields declared without the
static
keyword. Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object, in other words); thecurrentSpeed
of one bicycle is independent from thecurrentSpeed
of another. - Class Variables (Static Fields) A class variable is any field declared with the
static
modifier; this tells the compiler that there is exactly one copy of this variable in existence, regardless of how many times the class has been instantiated. A field defining the number of gears for a particular kind of bicycle could be marked asstatic
since conceptually the same number of gears will apply to all instances. The codestatic int numGears = 6;
would create such a static field. Additionally, the keywordfinal
could be added to indicate that the number of gears will never change. - Local Variables Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field (for example,
int count = 0;
). There is no special keyword designating a variable as local; that determination comes entirely from the location in which the variable is declared — which is between the opening and closing braces of a method. As such, local variables are only visible to the methods in which they are declared; they are not accessible from the rest of the class. - Parameters You've already seen examples of parameters, both in the
Bicycle
class and in themain
method of the "Hello World!" application. Recall that the signature for themain
method ispublic static void main(String[] args)
. Here, theargs
variable is the parameter to this method. The important thing to remember is that parameters are always classified as "variables" not "fields". This applies to other parameter-accepting constructs as well (such as constructors and exception handlers) that you'll learn about later in the tutorial.
- distinguish between variable and field
- Distinguish between pointers and references in C++
- 条款一:Distinguish between pointers and references
- Item 1: distinguish between pointers and references
- Item7 Distinguish between () and {} when creating objects
- How to distinguish between 32 and 64-bit JVM
- Distinguish Between Value Types and Reference Types - Effective C#学习笔记(6)
- Effective C#之6:Distinguish Between Value Type and Reference Type
- Effective C#之20:Distinguish Between Implementing Interfaces and Overriding Virtual Functions
- Basic distinguish between web.py / flup and tornado web process handling model (TBC)
- Distinguish between index of a decimal number and integer inside an array in Ruby?
- the difference between pointer and array (and variable)
- The difference between data references and field symbols
- Relation between Data References and Field symbols with examples
- The difference between declaring a variable “id” and “NSObject *”
- What's the difference between tf.placeholder and tf.Variable
- What’s the difference between a class variable and an instance variable?
- What are the differences between a pointer variable and a reference variable in C++?
- 90%男人会做的事
- 常用到的.net工具
- 肠胃炎又犯了,恼人,似乎和它结成了朋友.
- 网页背景渐变色
- Eclipse中优秀的插件
- distinguish between variable and field
- C++如何修改SDI程序的默认背景颜色
- 求职!C#+SQL SERVER
- Asp.net 2.0
- c++实现系统托盘图标
- c++继承关系
- Java Language Keywords
- ASP.NET的HTMLTable原样导出到Excel
- T-SQL编码函数