Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does implementation inheritance mean in the javadoc of java.sql.Timestamp?

From the JavaDoc of java.sql.Timestamp class(emphasis mine)

Due to the differences between the Timestamp class and the java.util.Date class mentioned above, it is recommended that code not view Timestamp values generically as an instance of java.util.Date. The inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance.

What does it mean to say implementation inheritance and not type inheritance? Is it a case of HAS-A vs IS-A?

like image 906
Geek Avatar asked Feb 13 '23 13:02

Geek


1 Answers

Basically, the documentation states that the fact that java.sql.Timestamp extends java.util.Date is an implementation detail, and you should not use Timestamp instances where you expect to get Date's functionality. Presumably, if java had the option (like C++ does), Timestamp would privately inherit from Date.

like image 166
Mureinik Avatar answered Feb 16 '23 02:02

Mureinik