1
我試圖找到從包含至少5個元素的Hashtable中獲取第一個項目的方法。我有這樣的:從Hashtable獲取第一個項目J2ME
Hashtable parkingSlots;
parkingSlots = new Hashtable();
parkingSlots.put("P1", null);
parkingSlots.put("P2", null);
parkingSlots.put("P3", null);
parkingSlots.put("P4", null);
parkingSlots.put("P5", null);
Enumeration gPL = parkingSlots.Keys();
While(gPL.hasMoreElements()){
String parkingNum = (String) gPL.nextElement();
**// Here I've this result: P1, P2, P3, P4, P5 but I want to get only the first item, in this case P1**
}