We are searching data for your request:
Upon completion, a link will appear to access the found materials.
Normally you can't call a method of a class without first creating an instance of that class. By declaring a method using the
statickeyword, you can call it without first creating an object because it becomes a class method (i.e. a method that belongs to a class rather than an object).
Static methods are used for methods that do not need to access to an object's state or only use static fields. For example, the main method is a static method:
public static void main(String args)
It is the starting point for a Java application and does not need to access an object's state. In fact, there aren't any objects created at this point. Any parameters that it needs can be passed as a
To find out more about using the
statickeyword have a look at Static Fields.