Difference between static and non static methods in java

A static method belongs to the class and a non-static method belongs to an object of a class. Static methods are useful if you have only one instance where you're going to use the method, and you don't need multiple copies (objects). Non-static methods are used if you're going to use your method to create multiple copies. Static example
public class TestClass { public static void main(String[] args) { display(); //there is no object create here because display is a static method } public static void display(){ System.out.println("Call from static method"); } }
Non-static example
public class TestClass { public static void main(String[] args) { TestClass tc = new TestClass(); tc.display(); //object create here because display is a non-static method } public void display(){ System.out.println("Call from non-static method"); } }
A static method can however be called both on the class as well as an object of the class. A static method can access only static members. A non-static method can access both static and non-static members because at the time when the static method is called, the class might not be instantiated.