Can you help me fix this loop please?
These are the methods
Accessor Methods
d1.getMonth() // returns the month as int 1..12
d1.getDay() // returns the day of the month, as an int
d1.getYear() // returns the year
d1.getMonthName() // returns the month as a String (e.g. “March") d1.getDayOfWeek() // returns the day of the week as a string (e.g.,
// “Friday”)
d1.equals(d2) // returns true if d1 is the same date as d2
// otherwise, returns false
d1.getShortDate() // returns the date as mm/dd/yyyy
d1.getMediumDate() // returns the date in the form of
//“November 2, 2010”
d1.getLongDate() // returns the date in the form of
// “Monday, November 2nd, 2010”
Mutator Methods
Date d = new Date(1,1,2012) ; // d is January 1, 2012 (a leap year)
d.next() ; // d is January 2, 2012
d.previous() ; // d is January 1, 2012
d.add(31) ; // d is February 1, 2012
d.subtract(32) ; // d is December 31, 2011
d.next() ; // d is January 1, 2012
d = new Date(3,1,2012) ; // d is March 1, 2012
d.previous() ; // d is now February 29, 2012
I think I see the logic error with my code. It will be infinite right? How can I fix it though?