ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

What happens when I remove the static modifier from main()?

If you remove the static modifier from the standard main() method it becomes an instance method. If you then try to execute class the Java runtime system will fail and report:
Exception in thread "main" java.lang.NoSuchMethodError: main.
If you restore the static modifier and change the return type to int, for example, you get the same error. The runtime system expects a static main() method with the void return type, if you change either of these properties you may create a valid method but it will not be executed by the java command.
Related Posts Plugin for WordPress, Blogger...
Flag Counter