First of all this is a Java code. Have you set the language to Java?
Second, in Java, every class has to go to its own file with the same name as the class itself. The default file you get is Main.java so your class must be called Main (not MyClass).
If you want to write your own class (MyClass) you have to create a new file (with the same name) and put the code there and call it from your Main.java file.