Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Static  RSS feed

 
Abhishek Bose
Greenhorn
Posts: 24
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Static members are loaded at runtime or compile time.....??
 
Buddhika Mawella
Ranch Hand
Posts: 40
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing called 'loading' when compiling. Compiling a java program is just converting your human readable java code in to a machine readable language when interpreted by JVM.
 
Abhishek Bose
Greenhorn
Posts: 24
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Buddhika Mawella wrote:There is nothing called 'loading' when compiling. Compiling a java program is just converting your human readable java code in to a machine readable language when interpreted by JVM.


i mean when it gets on to heap.....!
 
Buddhika Mawella
Ranch Hand
Posts: 40
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a java program is compiling there is nothing called heap or stack. Stack and heap only exist on runtime.
 
Campbell Ritchie
Marshal
Posts: 55681
161
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you actually mean is, "Are the static members of a class loaded into memory before or after an instance is created?"

As far as I know, they are part of the class file, which is loaded into memory by the class loader when the class is needed, before any instances are created. Search for the BCEL Manual, which is out of date, but still probably useful, or go through the JVM Specification.
 
Prasanna Kumaar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think its Runtime
 
Abhishek Bose
Greenhorn
Posts: 24
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Buddhika Mawella wrote:When a java program is compiling there is nothing called heap or stack. Stack and heap only exist on runtime.


So that means each and every member in a java program gets on to the heap during runtime and not before..?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhishek Bose wrote:
Buddhika Mawella wrote:When a java program is compiling there is nothing called heap or stack. Stack and heap only exist on runtime.


So that means each and every member in a java program gets on to the heap during runtime and not before..?

Heap or stack, yes. Remember, the program is probably compiled on a different computer to the one it is run on. So how can the memory of the running machine possibly be affected during compilation?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!