Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Viveka Fischer   on Mar 24 In Java Category.

  
Question Answered By: Erin Dunn   on Mar 24

They are not initialised at compile  time. They are initialised at
runtime, when the class  is loaded. The compiler  only adds the expression
to initialize the static  variable, in the .class file. For a primitive,
this can be a literal, like in 'int i=5;', so then there would be 4
bytes in the .class file that hold the integer value 5, and that will be
assigned to i when the class is loaded (or just after the class is loaded).

Share: 

 
 
Didn't find what you were looking for? Find more on static variables and methods Or get search suggestion and latest updates.


Tagged: