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.
There is code they give you behind the scenes. If you look before and after the section you can type in your code, there is a Solution class and a main they give you. You can expand these to see their code by clicking the double sided blue arrow on the display.
No u cant do it without static. As static members load into memory before anything else. So if the flag variable is not declared static then main wont have any value of flag! and thus an error my friend :)
Java Static Initializer Block
You are viewing a single comment's thread. Return to all comments →
There is code they give you behind the scenes. If you look before and after the section you can type in your code, there is a Solution class and a main they give you. You can expand these to see their code by clicking the double sided blue arrow on the display.
Hope this helps
hey I am new to JAVA but why we use static cant we do it without static?
No u cant do it without static. As static members load into memory before anything else. So if the flag variable is not declared static then main wont have any value of flag! and thus an error my friend :)
Exactly!