{"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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Java Code<\/span> <\/div> <pre class=\"language-java code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-java code-embed-code\">public class wiki {     <br\/>        public static void main(String[] args) {<br\/>            System.out.println(\u201cWikitechy welcomes you!&quot;);<br\/>        }<br\/>    }<br\/>    }<br\/><br\/>    1 error found:<br\/>    File: wikitechy.java  [line: 6]<br\/>    Error: class, interface, or enum expected<\/code><\/pre> <\/div>\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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Java Code<\/span> <\/div> <pre class=\"language-java code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-java code-embed-code\"> public class wiki {     <br\/>        public static void main(String[] args) {<br\/>            System.out.println(\u201cWikitechy welcomes you!&quot;);<br\/>        }<br\/>    }<\/code><\/pre> <\/div>\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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Java Code<\/span> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">import java.util.Random;<br\/>import java.Math.*;<br\/>import javax.swing.JOptionPane;<br\/>public static void wiki(String args[])<br\/>{<br\/>    \/\/ a bunch of code<br\/>}<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Java Code<\/span> <\/div> <pre class=\"language-java code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-java code-embed-code\">public class wiki{                             <br\/>   public static void wiki(String args[]){ ... }<br\/>}<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\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 SOLUTION 1 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 [&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}]}}