Learn Java
import com.learnjava.oopfundamentals.InstanceStaticMethods;

Instance Methods vs Static Methods in Java

@Concept

An instance method operates on a specific object — inside its body, it can freely read and modify that particular object's instance variables, and calling it requires an actual object to call it on. A static method belongs to the class itself, has no specific object associated with a call to it, and as a direct consequence, cannot access any instance variable or call any instance method directly — there's no particular object's data for it to reach for.

A static method can be called two ways that mean the same thing, ClassName.method() or through an instance reference, though the class-name form is the clearer, conventional one. An instance method, on the other hand, can only ever be called on an actual object, never on the class name alone.

@HowItWorks
1

Instance methods act on a specific object

They can read and modify that particular object's own instance variables directly.

2

Static methods act on the class

With no specific object involved, they cannot touch instance variables or call instance methods directly.

3

Calling an instance method

Requires an actual object, like myObject.doSomething().

4

Calling a static method

Conventionally through the class name, like ClassName.doSomething(), though calling it through an instance reference also works.

5

A static method can call another static method directly

But reaching an instance method or instance variable from inside a static one requires an actual object reference to do it through.

@Example
public class Circle {
double radius;
 
Circle(double radius) {
this.radius = radius;
}
 
double area() {
return Math.PI * radius * radius;
}
 
static double areaOf(double r) {
return Math.PI * r * r;
}
 
public static void main(String[] args) {
Circle c = new Circle(2);
System.out.println("Instance method: " + c.area());
System.out.println("Static method: " + Circle.areaOf(2));
}
}
Output
Instance method: 12.566370614359172
Static method: 12.566370614359172
1area() is an instance method, reaching directly into this particular Circle's own radius field.
2c.area() can only be called because c is an actual Circle object with its own radius already set.
3areaOf(double r) is static, taking the radius as an explicit parameter instead, since it has no particular object's field to read from.
4Circle.areaOf(2) is called through the class name directly, needing no Circle object to exist at all.
@UseCases
Writing a utility method, like Math.sqrt, that doesn't depend on any particular object's state
Reading or modifying one specific object's own data through an instance method
Understanding why a static method can't directly reference this or an instance variable
Deciding whether a new method belongs on the class itself or on each individual instance

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in Java yourself — building beats watching.