The whole idea of instance methods, like xyz
is in this, is that you are using the state of an instance of A
in the method, without having to pass that instance as an argument like this:
... String xyz(A thisInstance, ...) {...}
Instead you use:
A thisInstance = ...;
thisInstance.xyz(...);
That’s why you need an instance of A
, because it is practically an argument to the function.
However, if you don’t need an instance of A
, you can make the method static:
static String xyz(...) {...}
Then you can call it without passing an instance of A
:
A.xyz(...);
You can use a static import so that you don’t have to write A
:
import static A.xyz;
...
xyz(...);