2013년 5월 10일 금요일

Initializing a static variable

Static variables are initialized when a class is loaded. A class is loaded because the JVM decides it's time to load it.
Typically, the JVM loads a  class because somebody's trying to make a new instance of the class. As a programmer, you also have the option of telling the JVM to load a class, but you're  not likely to need to do that, In nearly all case, you're better off letting the JVM decide when to load the class.

And there are two guarantees about static initialization:

  1. Static variables in a class are initialized before any object of that class can be created.
  2. Static variables in a class are initialized before any static method of the class runs.
Static variables are initialized when the class is loaded. If you don't explicitly initialize a static variable(by assigning it a value at the time you declare it), it gets a default value, so int variables are initialized to zero.
Declaring, but not initializing, a static variable means the static variable will get the default value for that variable type, in exactly the same way that instance variables are given default values when declared.

댓글 없음:

댓글 쓰기

ETL 솔루션 환경

ETL 솔루션 환경 하둡은 대용량 데이터를 값싸고 빠르게 분석할 수 있는 길을 만들어줬다. 통계분석 엔진인 “R”역시 하둡 못지 않게 관심을 받고 있다. 빅데이터 역시 데이터라는 점을 볼때 분산처리와 분석 그 이전에 데이터 품질 등 데이...