Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
In Java, a static method is a method that belongs to a class rather than an instance of a class. The method is accessible to every instance of a class, but methods defined in an instance are only able to be accessed by that member of a class.
Java allows developers to define static methods, which are available to every instance of a class. In an instance of a class, the methods are able to access both variables in an instance and those belonging to a class, while static methods cannot access instance variables or methods directly. Instead, static methods have to use object reference. The most common use for static methods is to access static variables. They are accessed by the class name and a dot (.) followed by the name of a method. They are declared with the keyword "static" when defining a method. Static methods can be accessed without having to create a new object.