質問1:
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
リストをロックする方法を教えてもらえますか?