public ICommonDao commonDao = null;
/**
* 获取所有数据库表
*
* @return
*/
public List<DBTable> getAllDbTableName() {
return commonDao.getAllDbTableName();
}
在公司看到如上代码, 把接口设为null ,但是还是可以调用接口的方法 ,这是为什么. 有什么含义.
public ICommonDao commonDao = null;
/**
* 获取所有数据库表
*
* @return
*/
public List<DBTable> getAllDbTableName() {
return commonDao.getAllDbTableName();
}
在公司看到如上代码, 把接口设为null ,但是还是可以调用接口的方法 ,这是为什么. 有什么含义.
ICommonDao这是一个数据库接口,在大型项目当中可能要连接多个数据库类型,定义为接口的话,可以在运行的时候通过外部进行注入。然后在操作数据库。为null是在一开始不确定接口实现类型