We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
can some body explain the role of flag in the above example ?? why do we need a flag , what does it do?i tried the code without the flag but it dosent work!please help
see the main method
There it's written that print B*H (if and only if flag ==true)
And since we know that static block gets initialised as soon a s the class is loaded, So, as soon as the class is loaded and the values of B and H are loaded it's checked that is flag still equal to true
I HOPE THAT YOU GOT IT NOW
But still if you have any doubt feel free to ask
Java Static Initializer Block
You are viewing a single comment's thread. Return to all comments →
can some body explain the role of flag in the above example ?? why do we need a flag , what does it do?i tried the code without the flag but it dosent work!please help
see the main method There it's written that print B*H (if and only if flag ==true) And since we know that static block gets initialised as soon a s the class is loaded, So, as soon as the class is loaded and the values of B and H are loaded it's checked that is flag still equal to true
I HOPE THAT YOU GOT IT NOW But still if you have any doubt feel free to ask
yaa ..thank you very much brother ..