接口:TestDao 实现类:TestDaoimpl
现有如下3个问题:
1,private TestDao testdao 与private TestDao testdao = new TestDaoimpl()有什么区别?
2,我用前者调用实现类的方法的时候出现空指针异常,但又看到其他例子也用前者调用却没出现这种错误,这是为什么呢?
3, private TestService testService;
[color=red]public TestService getTestService() {
return testService;
}
public void setTestService(TestService testService) {
this.testService = testService;
}[/color]
不写红色部门会报错,这是为什么呢?红色部分有什么意义和用处?
小弟彻夜难眠?希望各位兄弟帮忙,谢谢!!