- Instance Variables (Non-Static Fields) Technically speaking, objects store their individual states in "non-static fields", that is, fields declared without the
statickeyword. 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); the
currentSpeedof one bicycle is independent from the
- Class Variables (Static Fields) A class variable is any field declared with the
staticmodifier; 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 as
staticsince conceptually the same number of gears will apply to all instances. The code
static int numGears = 6;would create such a static field. Additionally, the keyword
finalcould 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
Bicycleclass and in the
mainmethod of the "Hello World!" application. Recall that the signature for the
public static void main(String args). Here, the
argsvariable 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.
전역변수, 멤버변수, 로컬변수 등 다양한 이름의 변수들이 존재한다. 물론 의미만 통하면 개발자들 끼리 큰 문제는 없겠지만 정확한 명칭은 위와 같습니다. (Oracle Refrence 자료)
'인스턴스 변수'는 Static 이 아닌 변수를 의미합니다.
'클래스 변수'는 Static 으로 선언한 변수를 의미합니다.
'로컬 Variable' 변수는 method 안에서만 처리 되는 등 지역변수를 의미합니다. (쓰고 버려지는 변수를 의미합니다.)
'Android > 안드로이드 프로그래밍' 카테고리의 다른 글
|Android Readability API Goose Example (0)||2014.03.25|
|안드로이드 네비게이션 Back And Up (로고 클릭 시 부모액티비티로 이동) (0)||2014.03.03|
|자바/안드로이드에서 정확한 변수의 이름! (0)||2014.02.04|
|Why use fragment static constructor? (0)||2014.02.04|
|Eclipse clean and running in mac (0)||2013.12.17|
|Android Library 'Textile Textview' (0)||2013.12.06|