I have a simple Class. Zelle is a simple Enum.
public class Main {
public void getZelle (){
System.out.println(Zelle.RED);
}
public static void test(){
System.out.println(Zelle.Empty);
}
public static void main(String[] args) {
System.out.println("HEllo World");
}
}
If i want to open these Methods with the Jshell i get the following Errors which I do not understand:
jshell> Main.getZelle()
| Error:
| non-static method getZelle() cannot be referenced from a static context
| Main.getZelle()
| ^-----------^
jshell> Main.test()
| attempted to use class Main which cannot be instantiated or its methods invoked until variable Zelle is declared
jshell> Main.main(new String[0])
| attempted to use class Main which cannot be instantiated or its methods invoked until variable Zelle is declared
But if I run the main() in the IDE it will print my test() Method
public static void main(String[] args) {
test();
}