Carlos Cueto wrote:But year1 is the year parameter of the second Date object, if I add 1 to it in the loop, shouldn't the year change by 1 and thus the day of the week change as well?
You are comparing two different Date objects which are never equal, thus the loop runs infinitely.