Static method invocation

Yes you can. Check out static imports. You have to mention the class name in the import statement, but after that you don’t have to.e.g. from the linked article:

import static java.lang.Math.abs;
import static java.lang.Math.max;

int xDist = abs(destination.getX() - x);
int yDist = abs(destination.getY() - y);
return max(xDist, yDist);

Introduced in Java 5.

Leave a Comment