Set set = hm.entrySet();
Iterator i = set.iterator();
while (i.hasNext()) {
Map.Entry me = (Map.Entry)i.next();
// me.getValue should point to an arraylist
Iterator<Student> it = (me.getValue()).iterator();
while (it.hasNext()) {
// some code
}
}
好吧,我試着迭代Arraylist,由於某種原因它不起作用,編譯器告訴我它找不到符號。我知道me.getValue()應指向一個對象,在這種情況下,鍵/值對的值部分是Arraylist。那麼,怎麼了?在ArrayList的hashmap上迭代
郵政堆棧跟蹤請 – shinjw 2014-09-23 01:53:19
您的意思是生成輸出? – Redowl 2014-09-23 01:58:30
[什麼是堆棧跟蹤](http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors ),但它是在運行時生成的,而您的問題似乎是編譯時間之一。 – Pshemo 2014-09-23 01:59:15