0
0

More than 3 years have passed since last update.

【Java】ArrayListについて

Posted at

記述方法

ArrayListを使う記述方法は、以下の様に<>の中に格納したい型名を記述します。

Sample.java
import java.util.ArrayList;

public class Sample {
    public void main(String[] args) {
        ArrayList<String> array = new ArrayList<String>();
    }
}

特徴

宣言時のサイズ指定は不要

宣言時にサイズを指定しないため、データを追加しようとした時に自動的に追加されていく。

インスタンスでないものは格納できない

例えばint型は使えないので、Integerを使用する。

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