是否可以使用不可见构造函数扩展一个类,而不必知道该构造函数的作用并再次实现它?
import java.sql.DriverManager;
public class myDriverManager extends DriverManager {
public myDriverManager() {
super(); //Fehler: the constructor DriverManager() ist not visible
}
}
最佳答案
你不能扩展 DriverManager ,但您可以改为实现 DataSource
NOTE: The DataSource interface, new in the JDBC 2.0 API, provides another way to connect to a data source. The use of a DataSource object is the preferred means of connecting to a data source.
关于java - 使用私有(private)构造函数扩展类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62670689/