i am confused about the usage of static methods in java , for example it makes sense if main method is static , but while coding we have got objects for example
JFrame frame= new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// here why not frame.EXIT_ON_CLOSE
and same way when we use
GridBagConstraints c= new GridBagConstraints();// we have an object but still
c.anchor = GridBagConstraints.PAGE_END;
so can anyone please explain me the is there any special reasons for it ?
staticmeans there is no instance of an object associated with it. That's all, nothing special.mainmethod is static" no it doesn't, but I probably shouldn't start that kind of discussion in a Java-only question...