Variables 变量
Java 中有三种变量
- Fields (instance variables);
- They store values through the life of an object.
- They are accessible throughout the class.
- Parameters (temporory variables);
- They receive values from outside the method.
- They help a method complete its tas.
- Each call to the method receives a fresh set of values
- Parameter values are short lived.
- Local variables;
Scope highlight
如图, BlueJ 中的代码被各种颜色包裹, 每一块儿颜色就是一块儿 “scope”
scope 决定了 variable 访问的范围
以 fields (实例变量) 为例:
如图, fields 被绿色的 scope 所包围, 也就是整个 class, 那么 fields 就可以在整个