0
0

More than 3 years have passed since last update.

Java (add)

Last updated at Posted at 2019-10-31

Javaの勉強をしているので、備忘録としてUPします。

【add】
ArrayListに要素を追加する際に使用するメソッドである。

変数名.add()の中に追加したい値を入れて使用する。

ArrayList<String> array = new ArrayList<String>();

array.add("日本語");
array.add("英語");
array.add("フランス語");

リストの中を出力すると以下のようになる。

System.out.println(array);

日本語,英語,フランス語

この後に続けて追加すると以下のように、追加されていく。

array.add("中国語");
array.add("ドイツ語");

System.out.println(array);

日本語,英語,フランス語,中国語,ドイツ語
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