我有一个 MyDate 类,在这个类中,我需要检查年份(y)是否是闰年。我的代码如下:
public class MyDate
{
    private int d;
    private int m;
    private int y;
//constructor
public MyDate(int d, int m, int y)
    {
    this.d = d;
    this.m = m;
    this.y = y;
    }
    public void setDay(int d)
    {
        this.d = d;
    }
    public int getDay()
    {
        return d;
    }
    public void setMonth(int m)
    {
        this.m = m;
    }
    public int getMonth()
    {
        return m;
    }
    public void setYear(int y)
    {
        this.y = y;
    }   
    public int getYear()
    {
        return y;
    }
    public void setDate(int d, int m, int y)
    {
        setDay(d);
        setMonth(m);
        setYear(y);
    }
在这里而不是(int y),我需要使用getYear()吗?
public static boolean isLeap(int y) {
  if (y % 4 != 0) {
    return false;
  } else if (y % 400 == 0) {
    return true;
  } else if (y % 100 == 0) {
    return false;
  } else {
    return true;
  }
}
//像这样?
public static boolean isLeap(getYear()) {
  if (y % 4 != 0) {
    return false;
  } else if (y % 400 == 0) {
    return true;
  } else if (y % 100 == 0) {
    return false;
  } else {
    return true;
  }
}