Hallo,
ich habe folgende Objekt Modelle:
ich bekomme überall Daten zurück ausser bei getDetailsInfixId(), da wird eine NullPointerException geworfen. Warum funktioniert das so bei getDetailsDescription() aber bei getDetailsInfixId() nicht?
Das Objekt wird mit Daten gefüllt. Das sehe ich wenn ich es in ItemDetail auf der console ausgeben lasse.
ich habe folgende Objekt Modelle:
Code:
public class ItemMain{
private String type = null;
private ItemDetail details = new ItemDetail();
public String getType(){
return type;
}
public String getDetailsDescription(){
return details.getDescription();
}
public int getDetailsInfixId(){
return details.getInfix().getId();
}
}
public class ItemDetail{
private String description = null;
private InfixObject infix = new InfixObject();
public String getDescription(){
return description;
}
public InfixObject getInfix(){
return infix;
}
}
public class InfixObject{
private int id = 0;
public int getId(){
return id;
}
}
ich bekomme überall Daten zurück ausser bei getDetailsInfixId(), da wird eine NullPointerException geworfen. Warum funktioniert das so bei getDetailsDescription() aber bei getDetailsInfixId() nicht?
Das Objekt wird mit Daten gefüllt. Das sehe ich wenn ich es in ItemDetail auf der console ausgeben lasse.
Code:
public InfixObject getInfix(){
System.out.println(infix.getId());
return infix;
}