title | date | draft | tags | categories | |||
---|---|---|---|---|---|---|---|
算法4 Java解答 1.2.11 |
2019-02-22 07:35:22 +0800 |
false |
|
|
Develop an implementation SmartDate of our Date API that raises an exception if the date is not legal.
主要是判断月份和月份中有多少天
private static int[] bigmonths = {1, 3, 5, 7, 8, 10, 12};
private static int[] smallmonth = {4, 6, 9, 11};
static {
for (int i = 0; i < bigmonths.length; i++) {
months[bigmonths[i]] = 31;
}
for (int i = 0; i < smallmonth.length; i++) {
months[smallmonth[i]] = 30;
}
months[2] = 28;
}