“Class, Interface, Or enum Expected” error arises due to additional curly braces at end of Java program.
Considering an example where the file is named as wikitechy.java
We need to notice that two curly braces at the end of the program are at the same indentation level, which cannot happen in a valid program. So, if you get this same Class, interface or enum expected error next time, first check if there is an additional curly braces at end of program.
Simply delete one of the curly braces for the code to compile properly and check the code below :
We can also identify this kind of error by pressing CTRL-A (to highlight the entire program) and then TAB (to correctly indent the highlighted code)
Compiler error: “class, interface, or enum expected”
Considering an example where the file is named as wikitechy.java
[ad type=”banner”]In this program, class declaration(wiki) is missing . Check the Java code below :
[ad type=”banner”]