• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

scjp6 - enum question 2

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please don't repost the same question. your other post given at https://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
reply
    Bookmark Topic Watch Topic
  • New Topic