Sorry aber mir ist erstmal kein besserer Threadtitel eingefallen und zweitens ist das Problem wohl eh ganz leicht zu lösen:
Ich hab 2 Javaklassen, die eine erbst von der andren. die Oberklasse hat aber gleichzeitig ein ArrayObjekt der Unterklasse als Bestandteil.

Hier mal der Code:
Code:
package blatt3aufgabe3;

public class Publikation extends Projekt {
    
    public String Titel, Inhalt, Datum;
    public Autor[] autor;
    
    /** Creates a new instance of Publikation */
    public Publikation(){}
    
    
    public Publikation(String titel, String inhalt, String datum) {
        this.Titel = titel; this.Inhalt = inhalt; this.Datum = datum;
    }
    
    public Publikation(String titel, String inhalt) {
        this.Titel = titel; this.Inhalt = inhalt; 
    }
    
    public Publikation(String titel) {
        this.Titel = titel;
    }

 public static void main(String[] args) {
        Publikation pub = new Publikation("Saudummertitel", "blablabla", "31.02.2005");
        pub.autor[0] = new Autor("Nachname", "Vorname", "1.1.1111");
    }
}
Und die Unterklasse davon:

Code:
package blatt3aufgabe3;

/**
 *
 * @author martin
 */
public class Autor extends Publikation {
    
    public String Name, Vorname, Geburtsdatum;
    
    /** Creates a new instance of Autor */
    
    public Autor(String name, String vorname, String geburtsdatum) {
        super();
        this.Name = name;
        this.Vorname = vorname;
        this.Geburtsdatum = geburtsdatum;
    }
    
    public String toString() {
        return new String("Name: "+this.Name+" Vorname: "+this.Vorname+" Geburtsdatum: "+this.Geburtsdatum);
    }
    
}
Wenn ich das ganze aber jetz versuche laufen zu lassen erhalte ich immer:
Exception in thread "main" java.lang.NullPointerException
at blatt3aufgabe3.Publikation.main(Publikation.java:4 1)
Java Result: 1
Das ist die zeile mit pub.autor[0] = ....

Wen nich das Array weglasse und ein einzelnes Objekt nehme würde es gehen...
Was hab ich falsch gemacht?