| Author |
scjp6 - enum question 2
|
Srinivas Palam
Ranch Hand
Joined: Oct 20, 2005
Posts: 39
|
|
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
Joined: Jan 15, 2012
Posts: 60
|
|
|
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
Joined: Apr 04, 2012
Posts: 868
|
|
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
|
OCPJP 6(100 %) OCEWCD 6(91 %)
|
 |
 |
|
|
subject: scjp6 - enum question 2
|
|
|