-1

人们,我需要你的帮助来解决这个问题,因为我找不到合适的解决方案来解决它。

问题是:

**Exception in thread "main" java.lang.NullPointerException
    at edu.maimonides.www.progmul3.tps.tp1.Garage.park(Garage.java:57)
    at edu.maimonides.www.progmul3.tps.tp1.GarageElPlus.main(Garage.java:29)
Java Result: 1**

// 翻译:汽车 = 汽车 - 摩托 = 摩托车 - Camioneta = 货车

**Class Park Slot**

public class Park Slot {


  private ArrayList<Integer> bigParkSlot =  
       new ArrayList<>(Arrays.asList(1, 3, 5, 7, 9, 11));
   private ArrayList<Integer> avaliableParkSlot =  
       new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
              11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22));
   private Map<Integer, String> busyParkSlot = new HashMap<>();
   private ArrayList uncoveredParkSlot =  
       new ArrayList<>(Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20));
   private ArrayList coveredParkSlot = 
       new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));

   }

   **Class Garage**  

    // Line 57
    // the problem is here

   ArrayList<Integer> pElem = c.getavaliableParkSlot();

   int num = pElem.iterator().next();
4

2 回答 2

1

我在这里很快发现了这个问题:

private Park Slot c;

解决方案在这里:

private Park Slot c = new Park Slot();
于 2012-09-18T00:34:13.820 回答
0

c变量分配在哪里?它可能是空的。

于 2012-09-18T00:28:20.327 回答