Wednesday 23 November 2011

How things are initialized in java program inside jvm ..

hello every one i am tushar , good morning to all of you ,i m from india the best country of this world . and its honor to me that i am indian and writing blogs for my love 'java' . and today i am dealing with " How things are initialized in java program inside jvm  .. " .


so for me programming is not important , i love my state when i deal with basics . so in java i always prefer basics , than programming because basics are the the root of everything . so thats why i always deal with jvm specification .


when we perform or implement any-thing inside java program . every thing in initialized thats why initialization is the first step of every process . so inside java/jvm we have two statements for initialization they are <init> & <clinit> . 


<init> :---- this statement is used for initializing the instance       variable of java program . 


<clinit> :-- this statement is used for initializing the class type variables in a java program .


now think about what will happen in this case .
now what will happen for this program , now do you ever think that how things are initialized means its lies inside the instance variable category but these are initialized at static variable but we have only two initializer <init> and <clinit
and they are found inside jvm so the question rises is , how can you say that " int a = 10 and double d = 29 " can initialized at the compile time . so for this java/jvm operate this problem by constructor and initialized them inside constructor . like ...


now it is clear that no matter where you initialized values of instance variables , every thing is initialized in constructor if you are declaring them as a instance variables . 

                                                  .thanks tushar

No comments: