{"id":1117,"date":"2017-03-20T09:49:41","date_gmt":"2017-03-20T04:19:41","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=1117"},"modified":"2018-10-23T19:03:12","modified_gmt":"2018-10-23T13:33:12","slug":"class-interface-enum-expected","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/class-interface-enum-expected\/","title":{"rendered":"Class, Interface, Or enum Expected error"},"content":{"rendered":"<h2 id=\"problem\"><span style=\"color: #333399;\"><label class=\"label label-warning\">PROBLEM:<\/label><\/span><\/h2>\n<p>\u201cClass, Interface, Or <a href=\"https:\/\/www.wikitechy.com\/technology\/lookup-enum-string-value\/\" target=\"_blank\" rel=\"noopener\">enum<\/a> Expected\u201d error arises <strong>due to additional curly braces<\/strong> at end of <a href=\"https:\/\/www.wikitechy.com\/technology\/java-programming-compare-two-strings-represented-linked-lists\/\" target=\"_blank\" rel=\"noopener\">Java program<\/a>.<\/p>\n<p>Considering an example where the file is named as wikitechy.java<\/p>\n[pastacode lang=\u201djava\u201d manual=\u201dpublic%20class%20wiki%20%7B%20%20%20%20%20%0A%20%20%20%20%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20System.out.println(%E2%80%9CWikitechy%20welcomes%20you!%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%201%20error%20found%3A%0A%20%20%20%20File%3A%20wikitechy.java%20%20%5Bline%3A%206%5D%0A%20%20%20%20Error%3A%20class%2C%20interface%2C%20or%20enum%20expected%0A\u201d message=\u201dJava Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h3 id=\"solution-1\"><span style=\"color: #008000;\"><label class=\"label label-info\">SOLUTION 1<\/label><\/span><\/h3>\n<p>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 <a href=\"https:\/\/www.wikitechy.com\/technology\/computer-networks-error-detection\/\" target=\"_blank\" rel=\"noopener\">error<\/a>\u00a0next time, first check if there is an additional curly braces at end of program.<\/p>\n<h3 id=\"solution-2\"><span style=\"color: #008000;\"><label class=\"label label-info\">SOLUTION 2<\/label><\/span><\/h3>\n<p>Simply delete one of the curly braces for the code to compile properly and check the code below :<\/p>\n[pastacode lang=\u201djava\u201d manual=\u201d%20public%20class%20wiki%20%7B%20%20%20%20%20%0A%20%20%20%20%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20System.out.println(%E2%80%9CWikitechy%20welcomes%20you!%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A\u201d message=\u201dJava Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h3 id=\"solution-3\"><span style=\"color: #008000;\"><label class=\"label label-info\">SOLUTION 3<\/label><\/span><\/h3>\n<p>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)<\/p>\n<h2 id=\"problem-2\"><span style=\"color: #333399;\"><label class=\"label label-warning\">PROBLEM:<\/label><\/span><\/h2>\n<p><strong>Compiler error:<\/strong> \u201cclass, interface, or enum expected\u201d<\/p>\n<p>Considering an example where the file is named as wikitechy.java<\/p>\n[pastacode lang=\u201djavascript\u201d manual=\u201dimport%20java.util.Random%3B%0Aimport%20java.Math.*%3B%0Aimport%20javax.swing.JOptionPane%3B%0Apublic%20static%20void%20wiki(String%20args%5B%5D)%0A%7B%0A%20%20%20%20%2F%2F%20a%20bunch%20of%20code%0A%7D%0A\u201d message=\u201dJava Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\n<h3 id=\"solution-4\"><span style=\"color: #008000;\"><label class=\"label label-info\">SOLUTION 4<\/label><\/span><\/h3>\n<p>In this program,\u00a0 class declaration(wiki) is missing . Check the <a href=\"https:\/\/www.wikitechy.com\/technology\/java-constructor-tutorial-code-examples\/\" target=\"_blank\" rel=\"noopener\">Java code<\/a> below :<\/p>\n[pastacode lang=\u201djava\u201d manual=\u201dpublic%20class%20wiki%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20public%20static%20void%20wiki(String%20args%5B%5D)%7B%20\u2026%20%7D%0A%7D%0A\u201d message=\u201dJava Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\n","protected":false},"excerpt":{"rendered":"<p>PROBLEM: \u201cClass, Interface, Or enum Expected\u201d error arises due to additional curly braces at end of Java program. Considering an example where the file is named as wikitechy.java [pastacode lang=\u201djava\u201d manual=\u201dpublic%20class%20wiki%20%7B%20%20%20%20%20%0A%20%20%20%20%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20System.out.println(%E2%80%9CWikitechy%20welcomes%20you!%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%201%20error%20found%3A%0A%20%20%20%20File%3A%20wikitechy.java%20%20%5Bline%3A%206%5D%0A%20%20%20%20Error%3A%20class%2C%20interface%2C%20or%20enum%20expected%0A\u201d message=\u201dJava Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/] SOLUTION 1 We need to notice that two curly braces at the end of the program are at the same [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2139],"tags":[2340,2347,85564,2331,2334,2333,2346,2345,2332,2330,2336,2344,2342,2338,2337,2335,2341,2348,2343,2339,2329],"class_list":["post-1117","post","type-post","status-publish","format-standard","hentry","category-java","tag-basic-java-error-class","tag-class","tag-class-interface-or-enum-error-in-java-package","tag-class-interface-or-enum-expected-netbeans","tag-class-interface-or-enum-expected-public-static-void-mainstring-args","tag-class-or-interface-expected-error-in-java","tag-compiling-error-class","tag-enum-expected","tag-error-class-interface-or-enum-expected-android-studio","tag-error-class-interface-or-enum-expected-package","tag-error-class-expected","tag-error-class","tag-how-to-fix-class","tag-interface","tag-java-compiler-error-class","tag-java-class-interface","tag-java-error-class","tag-or-enum-expected-errors-in-bulk-solved","tag-or-enum-expected-error-in-java","tag-or-enum-expected","tag-what-does-class-interface-or-enum-expected-mean"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/1117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=1117"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/1117\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=1117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=1117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=1117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}