Hi to all Ranchers,
Could anyone please explain me why the output of the following program is "same old" instead of "newly new"?
I was just wondering ,at line 8,what would be the result if we place 'continue' instead of 'break'?
Please explain how this for loop is going to behave exactly?
public class McGee {
4. public static void main(
String[] args) {
5. Days d1 = Days.TH;
6. Days d2 = Days.M;
7. for(Days d: Days.values()) {
8. if(d.equals(Days.F)) break;
9. d2 = d;
10. }
11. System.out.println((d1 == d2)?"same old" : "newly new");
12. }
13. enum Days {M, T, W, TH, F, SA, SU};
14. }
Appreciate your help.
-DJ