corrected your code so that it should compile
you left a blankspace(whitespace) in your class name
here the for loop is ineffective on the output of the program
since it ends up at next line see there are no openinig closing curly braces around the for loop
values() is a static method which gets the value of enum according to their index d2[2]
here we are providing index 2 which is WED in your enum
thus the output is WED
hope this solves your problem.
dilip kumarr wrote:
kathy sierra question doubt scjp 1.6
anyone please help me solving this code..... please explain in detail, dont forget to explain code no.4 and 6
thanks in advance
it a simple code.............
donot panic for this
what
for (Days d: Days.values() ); is doing is it is putting all the values of enum into a array days............if you remove this.......ur code will also compile fine............try it...
same for
Days [] d2 = Days.values();
so,when you see d2[2]..........it will pring d2 at index 2 which is WED