Can we call static method via a temp variable?
There is a class AA
class AA {
static void test() {
}
}
class Main {
public static void main(String[] args) {
var aa = AA;
aa.test(); // Can we call static method via a temp vairble ?
}
}
Why I have the question? Because I must modify all the instance call style to class static style in my refactor work. The method was an instance method before and use a local variable to call it and now it became a static method or class. So I consider if there is way that just modify the variable. Maybe it's naive.
Directly, maybe like this, but not right.
Class<AA> aa = AA;
aa.test();
I know it's not good way to call static method by a instance as well.
And we know there is a way in Java 8 to refer a function. So is there another more meta capability to refer a literal class?