Okay, so don't ask why, but I'm trying to make a universal public static void main()
method. I've already tried to use these two methods;
public class Foo {
public static void main(String[] args){
try {
this.getClass().newInstance().check();
} catch(Exception e) {
e.printStackTrace();
}
}
public void check() {
System.out.println("Check succesful");
}
}
The error I get is that this
"Cannot be used in a static context"
Okay, so I know I can't use this
in a static context, but what I want to know is how I can replace it, without using Foo.check()
If possible, how should I do this? If not, I'd like to know why.