問題1幾個問題:上的ArrayList
是否有意義specifiy ArrayList的大小。我知道列表中會包含多少元素,事先指定大小還是不重要的。
List<String> list = new ArrayList<String>(1);
list.add("Hello");
List<String> newList = new ArrayList<String>();
newList.add("Hello");
問題2:
,當你操作(添加,刪除)的集合而遍歷同一集合時發生java.util.ConcurrentModificationException。 Does that mean there is a thread which is modifying the ArrayList and another Thread iterating the same object.
問題3
誰能告訴我怎樣可以鎖定一個列表?
@halex:修正,謝謝。 –