Runtime vs compile time memory allocation in java

前端 未结 4 2100
野的像风
野的像风 2021-01-03 06:11

I am confused regarding whether memory allocation in java occurs at run time or compile time.

For example:

class Test{
  int a;
  public Test(){
             


        
4条回答
  •  猫巷女王i
    2021-01-03 06:39

    In java a class is not loaded until unless its object is created which are created at runtime so any member variables like "a" in yours will get space when class is loaded same goes for object it will be allocated space at run time.

提交回复
热议问题