为什么这个java程序运行不出结果啊?

2024-11-28 16:38:50
推荐回答(1个)
回答1:

class Mydate {
private int year, month, day;

public String getDate() {
return year + "/" + month + "/" + day;
}

public int setDate(int y, int m, int d) {
if ((m > 0 && m <= 12) && (d > 0 && d <= 31)) {
year = y;
month = m;
day = d;
return 0;
} else {
return 1;
}
}
}

public class TestMyDate {
public static void main(String[] args) {
Mydate d = new Mydate();
if (d.setDate(2011, 11, 5) == 0)
System.out.println(d.getDate());
}
}