通过StationService类调用接口StationDao方法获取NullPointerException,该类在StationDaoImpl类中实现

时间:2016-10-14 09:14:55

标签: java interface

我的代码就像

public class StationService 
{
private  StationDao stationDao;

public StationService(StationDao stationDao) {
     this.stationDao = stationDao;
}

public void insertData(PoliceStationBeans beans) {
    // TODO Auto-generated method stub
    System.out.println("In Implementation:"+beans.getArea()+""+beans.getUserName()
            +""+beans.getPassword()+""+beans.getEmail());

     stationDao.insertData(beans); //Getting Error Here
}
}

如何解决此错误 我提到了这个问题Can i call a method which is inside an interface without implementing the interface?

0 个答案:

没有答案