0
0

More than 3 years have passed since last update.

ArrayList配列でwhileによる繰り返し処理でIteratorで全部表示する

Last updated at Posted at 2019-11-01

ArraylistをIteratorで全件表示する方法

java

        //Listの宣言
        List<String> fruits =new ArrayList<>();

        fruits.add("リンゴ");
        fruits.add("スイカ");
        fruits.add("ナシ");
        fruits.add("バナナ");

       //Iterator<Stromg>の宣言 
    Iterator<String> it2= fruits.iterator();

        //hasNextを使用して値がある場合はループを継続する
        while(it2.hasNext()){
            //nextを使用して値を取得する
            String nation = it2.next();
            System.out.println(nation);
        }
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