Wednesday, August 4, 2010

Enums: TestDays.java

Courtesy of SCJP Sun® Certified Programmer for Java™ 6 Study Guide Exam (310-065) (9780071591065)
Chapter 1, Question 8



The for loop on lines 4 and 5 have no effect on the code. Output of this program is WED.

values() is a static method of enum that returns an array of enum's values. In this program, the array of Days values are being assigned to d2, which is an array of Days. Since the index of arrays start at 0, index 2 corresponds to WED.


No comments:

Post a Comment