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