This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Could anyone explain what the Month2 variable looks like. Also what does the month array look like? I thought the Month2 variable was an object of several objects namely JAN, FEB AND MARCH, but when a reference is made with m it refers to one of the objects, JAN. Also, what does month look like. I thought it would be an array called month where each element contains a month2 object. Something like: month 0 JAN refers to new Month2("January") 1 FEB refers to new Month2("February") 2 MAR refers to new Month2("March") Thank you in advance,
(edited by Cindy to format code) [This message has been edited by Cindy Glass (edited May 07, 2001).]
The month variable is an array of Month2's. The JAN variable is a variable of type Month2 that holds a string "January"; Same for FEB and MAR. These 3 are in addition to the month array, and were passed to the array when creating it. Because they declared the 3 Month2 variables in line it is harder to see off the bat, but it is the same as saying public final static Month2 JAN = new Month2("January"); public final static Month2 FEB = new Month2("February"); public final static Month2 MAR = new Month2("March"); So since there are 4 variables, you can refer to any one of them.
"JavaRanch, where the deer and the Certified play" - David O'Meara