Guten Morgen Zusammen,
ich verstehe grade die Welt nicht mehr.
ich hab mir für mein Programm eine Klasse erstellt in der ich noch einige zusätzliche Informtionen speichern möchte.
Wenn diese Methode aufgerufen wird, bekomme ich aber diese Meldung :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot assign field "BoxcardName" because "array[0]" is null
at MainWindow.schachtelEinlesen(MainWindow.java:188)
Vorher habe ich dafür ein StringArray erzeugt und das funktioniert problemlos.
ich verstehe grade die Welt nicht mehr.
ich hab mir für mein Programm eine Klasse erstellt in der ich noch einige zusätzliche Informtionen speichern möchte.
Java:
package classes;
public class Boxdata {
public String BoxcardName = "";
public String BoxardPath="";
public String BoxdataName="";
public String BoxGraphicsPath="";
}
Java:
//Schachtelpfad auswählen und einträge in Combobox schreiben
public Boxdata[] schachtelEinlesen(String path, String filter, JComboBox<String> cmb, Boolean uuid) {
File f = new File(path);
File[] l = f.listFiles();
// String[] array = new String[l.length + 1];
// Boxdata[] array = new Boxdata[l.length + 1];
Boxdata[] array = new Boxdata[1000];
int y = 1;
System.out.println(array.length);
array[0].BoxcardName = "keine Schachtel ausgewählt";
cmb.addItem(array[0].BoxcardName);
for (int i = 1; i < l.length; i++) {
if (l[i].getName().contains(filter)) {
if (uuid == true) {
array[y].BoxcardName = l[i].getName();
System.out.println(array[y]);
cmb.addItem(array[y].BoxcardName);
y++;
} else {
array[y].BoxcardName = l[i].getName();
array[y].BoxcardName = zerschnippel(array[y].BoxcardName, ".");
cmb.addItem(array[y].BoxcardName);
y++;
}
}
}
return array;
}
Wenn diese Methode aufgerufen wird, bekomme ich aber diese Meldung :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot assign field "BoxcardName" because "array[0]" is null
at MainWindow.schachtelEinlesen(MainWindow.java:188)
Vorher habe ich dafür ein StringArray erzeugt und das funktioniert problemlos.