M
Malcolm
Gast
Hallo,
kann mir einer sagen warum folgender Code eine NullPointerException verursacht?
kann mir einer sagen warum folgender Code eine NullPointerException verursacht?
Code:
public class ABC {
private JLabel lbl = new JLabel(); //ohne text
public JLabel getLabel() {
return this.lbl; //gibt ein Label zurück
}
}
public class XYZ {
private JLabel lbl;
public XYZ() {
//Ich mach das mal im Konstruktor
ABC abc = new ABC();
this.lbl = abc.getLabel();
lbl.setText("Der Label Text");
}
}