$ I write a code to count how many sundays in a given month. But it does not work, can anyone help me, please repair it. Thanks.
import java.util.Calendar;
public class Sundays {
int count;
public int getSundays(int month,int year)
{
Calendar calendar=Calendar.getInstance();
calendar.set(year, month-1,1);
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int dayofWeek = calendar.get(Calendar.DAY_OF_WEEK);
for(int day =1;day <=daysInMonth;day++) {
calendar.set(year, month-1,1);
if(dayofWeek==0);
{count++ ;
}
}
return count;
}
public static void main(String[] args)
{
Sundays d= new Sundays();
int e= d.getSundays(2,2015);
System.out.println(e);
}
}