Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

scjp6 - enum question 2

 
Srinivas Palam
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to scjp6 certification book, below code output is WED, but I am getting compiliation error. Please help.

public class TestDays {
4. public enum Days { MON, TUE, WED };
5. public static void main(String[] args) {
6. for(Days d : Days.values() )
7. ;
8. Days [] d2 = Days.values();
9. System.out.println(d2[2]);
10. }
11. }


D:\Java>javac TestDays.java
TestDays.java:2: ';' expected
public enum Days {MON, TUe, WED};
^
TestDays.java:4: ';' expected
for (Days d: Days.values())
^
TestDays.java:6: '.class' expected
Days [] d2 = Days.values();
^
TestDays.java:7: ')' expected
System.out.println(d2[2]);
^
4 errors

D:\Java>
 
ayush raj
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use code tags. Telling you this once again . The code snippet you provided runs just fine in my JVM . Try re-compiling your code .
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please don't repost the same question. your other post given at http://www.coderanch.com/t/593833/java-programmer-SCJP/certification/Scjp-enum is asking about the exactly same thing you are asking here. i have answered it at your other post. please check the reply there.
regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic