我有点混淆这段代码。它一直给我“Determ Null Pointer”的错误。Deferred空指针错误
bookStore.java
@Override
protected store createOutlet (String storeName, String storeType) {
store theStore = null;
theStore.setStoreName(storeName); //getting Deferencing Null Pointer Error
theStore.setStoreType(storeType);
return theStore;
}
storeProducer.java
public abstract class storeProducer {
protected abstract store createOutlet(String storeName, String storeType);
public store createNewStore(String storeName, String storeType) {
store newStore = createOutlet(storeName, storeType);
newStore.createStore();
return newStore;
}
store.java
public abstract class store extends Observable {
abstract void createStore();
什么是问题?我已经尝试抛出异常,但仍然无法正常工作。
你觉得'店theStore = NULL;'呢? –
我是它的软件,但如果我删除它,我的变量“theStore”将显示未初始化。但如果我创建一个实例它显示商店的错误是抽象的,不能立即。 –
你**必须拥有一个具体的'store'类型才能在运行时使用它。使用它。 –