The following code gives error because i am not put static keyword to main method. Please explain why main method not working without static keyword.
public class Test { public void main(String args[]) { try { int a = new Integer(10); System.out.println(a); } catch (Exception e) { System.out.println(e); } } }
Error:Main method is not static in class Test, please define the main method as: public static void main(String[] args)
mainmethod. It's a requirement of the language, why should it be anything else?Testto call it.