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.
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 :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Static Initializer Block
You are viewing a single comment's thread. Return to all comments →
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 :)