0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

配列とリストの違い

Posted at

配列(Array)とリスト(List)の違い

データを格納するためのデータ構造

  • 固定サイズか可変サイズ

配列:固定サイズ
作成時にサイズを指定したら、その後はサイズの変更不可
リスト:可変サイズ
要素を動的に追加、削除、変更可能

  • データ型の制約
    配列:単一のデータ型要素のみを格納
    リスト:ジェネリックを使用、異なるデータ型の要素を格納できる

  • メモリの管理
    配列:連続したメモリブロックとして割り当てられる
    リスト:内部的には連結リストやダイナミック配列などのデータ構造を使用して実装されている
    →リストは必要に応じてメモリを動的に管理

  • 操作の便利さ
    リスト:操作を行いやすくするための多くの便利なメソッドがある
    要素の追加、削除、検索など
    配列:基本的な操作のみ
    手動で要素を移動させる必要がある

配列は固定サイズで特定のデータ型の要素を格納する場合に適している
リストは可変サイズで異なるデータ型の要素を追加、削除、変更する必要がある場合に適している

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?