我打算要創造一個新的對象的方法,所以我可以更新方法,每次我把它叫做創建新對象錯誤JAVA的Android
這裏是代碼:
public class CollectedData {
List<BusSearchOuterDataResults> busData = new ArrayList<BusSearchOuterDataResults>();
public BusSearchOuterDataResults outerData;
public void createNewOuterDataObject(){
outerData = new BusSearchOuterDataResults();
this.outerData = outerData;
}
public void createNewInnerDataObject(){
outerData.createNewInnerDataObject();
}
public void addAllCollectedData(){
busData.add(outerData);
}
public List<BusSearchOuterDataResults> getBusData(){
return busData;
}
}
這是爲什麼當我調用createNewOuterDataObject方法時,它不會讓我創建一個新的,因爲我調用createNewOuterDataObject的類obj時沒有任何初始化?
public class BusSearchOuterDataResults {
List<BusSearchInnerDataResults> innerData = new ArrayList<BusSearchInnerDataResults>();
private String routeNo;
private String routeLabel;
private String direction;
public BusSearchInnerDataResults innerDataOBJ = new BusSearchInnerDataResults();
public BusSearchOuterDataResults(String routeNo, String routeLabel, String direction){
this.routeNo = routeNo;
this.routeLabel = routeLabel;
this.direction = direction;
}
public BusSearchOuterDataResults(){
}
public void createNewInnerDataObject(){
BusSearchInnerDataResults innerDataOBJ = new BusSearchInnerDataResults();
this.innerDataOBJ = innerDataOBJ;
}
public void addAllCollectedData(){
innerData.add(new BusSearchInnerDataResults());
}
public void setRouteNo(String routeNo){
this.routeNo = routeNo;
}
public void setRouteLabel(String routeLabel){
this.routeLabel = routeLabel;
}
public void setDirection(String direction){
this.direction = direction;
}
public String getrouteNo(){
return routeNo;
}
public String getrouteLabel(){
return routeLabel;
}
public String getdirection(){
return direction;
}
public List<BusSearchInnerDataResults> getData(){
return innerData;
}
}
你是什麼意思_it不會讓你創建一個新的one_? –
在我的ADT日食中,我放了一些像這樣的Lod.d(「INITIALIZING」,「WAIT」); dc.createNewInnerDataObject(); Lod.d(「SUCCESS」,「SUCESS」);但成功的日誌永遠不會顯示初始化後 –
這是什麼意思...? –