jeudi 4 juin 2015

nullpointer exception - arrayerstellung

hallo community,
ich werde und werde nicht schlauer. mein programm schreitet foran, im moment bin ich an einer speicherschnittstelle.
das speichern klappt schon wunderbar. das laden funktioniert soweit auch. allerdings (obwohl es grundsätzlich alles lädt) bekomme ich eine nullpointer exception. und zwar in diesem teil:
Java Code:

  1. for (int i = 0; i < key.length; i=i+2) {//combine the keys with the returnvalues to put them into the "overall" config which stors the last opened settings so you dont have to type twice ;)
  2. valuestogether[i]=key[i];
  3. valuestogether[i+1]=returnvariables[i];
  4. }


die beiden strings die ich zusammenführen möchte werden folgendermaßen initialisiert:
Java Code:

  1. String[] returnvariables;//to put the variables in you will return
  2. String[] valuestogether = null;
  3. String[] key = {//inicialize array for property.get
  4. "Jumpdistance_unladen",
  5. "Jumpdistance_laden",
  6. "Maximum_capacity",
  7. "Shipinsurance",
  8. "Shipsize",
  9. };


Java Code:

  1. returnvariables = conf.getConf(loadshipcombobox.getSelectedItem().toString(), key);

beide arrays die ich zusammenführen will haben nirgends "null" woher also kommt das?!?

Fehlermeldung:
Java Code:

  1. Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  2. at tradedangerous.ui.Interface.loadshipbtnActionPerformed(Interface.java:1430)
  3. at tradedangerous.ui.Interface.access$200(Interface.java:19)
  4. at tradedangerous.ui.Interface$3.actionPerformed(Interface.java:761)
  5. at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
  6. at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
  7. at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
  8. at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
  9. at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
  10. at java.awt.Component.processMouseEvent(Component.java:6516)
  11. at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
  12. at java.awt.Component.processEvent(Component.java:6281)
  13. at java.awt.Container.processEvent(Container.java:2229)
  14. at java.awt.Component.dispatchEventImpl(Component.java:4872)
  15. at java.awt.Container.dispatchEventImpl(Container.java:2287)
  16. at java.awt.Component.dispatchEvent(Component.java:4698)
  17. at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
  18. at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
  19. at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
  20. at java.awt.Container.dispatchEventImpl(Container.java:2273)
  21. at java.awt.Window.dispatchEventImpl(Window.java:2719)
  22. at java.awt.Component.dispatchEvent(Component.java:4698)
  23. at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:740)
  24. at java.awt.EventQueue.access$300(EventQueue.java:103)
  25. at java.awt.EventQueue$3.run(EventQueue.java:699)
  26. at java.awt.EventQueue$3.run(EventQueue.java:697)
  27. at java.security.AccessController.doPrivileged(Native Method)
  28. at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
  29. at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
  30. at java.awt.EventQueue$4.run(EventQueue.java:713)
  31. at java.awt.EventQueue$4.run(EventQueue.java:711)
  32. at java.security.AccessController.doPrivileged(Native Method)
  33. at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
  34. at java.awt.EventQueue.dispatchEvent(EventQueue.java:710)
  35. at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
  36. at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
  37. at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
  38. at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
  39. at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
  40. at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)


nullpointer exception - arrayerstellung

0 commentaires:

Enregistrer un commentaire