public class test{
public static void main(String[] args){
Date nowdate=new Date();
System.out.println("the year is"+nowdate.getYear());
}
}
为什么不能使用java.sql.Date的父类java.util.Date中的构造函数Date()呢?
...全文
184打赏收藏
一个关于继承的问题
import java.sql.Date; public class test{ public static void main(String[] args){ Date nowdate=new Date(); System.out.println("the year is"+nowdate.getYear()); } } 为什么不能使用java.sql.Date的父类java.util.Date中的构造函数Date()呢?
Class B extends Class A.
Class C extends Class B.
Then, if in Class B, there exists any Constructor, The Constructors in Class A is no longer available to Class C.
A lot of people never notice that, but that's exactly your problem. However, if you don't have any particular reason, it's not recommended to use java.sql.Date.
Use java.util.Date or java.util.Calendar.