Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
配列リスト ( ) から要素を削除するとarrayList.remove(int n)、残りのすべての要素が自動的に左にシフトされます。
arrayList.remove(int n)
要素がその位置を維持することは可能であると思っていました。したがって、たとえば、位置 2 の要素が削除された場合、位置 3 の要素を位置 2 に移動せずにそのままにしておきます。ありがとう
list.set(2, null);
これは、インデックス 2 の要素を null に置き換えるだけで、目的の結果が得られます。