How to get enumeration over ArrayList in Java

1 Answer

0 votes
public class JavaApplication1 {

    public static void main(String[] args) {

        ArrayList arrList = new ArrayList();

        arrList.add("a");
        arrList.add("b");
        arrList.add("c");
        arrList.add("d");
        arrList.add("e");
        arrList.add("f");
        arrList.add("g");

        Enumeration e = Collections.enumeration(arrList);

        while (e.hasMoreElements()) 
            System.out.println(e.nextElement());
  }
}
  
/*
run:

a
b
c
d
e
f
g

*/

 



answered Sep 25, 2016 by avibootz

Related questions

1 answer 171 views
3 answers 204 views
204 views asked Jan 21, 2022 by avibootz
2 answers 186 views
186 views asked Sep 5, 2020 by avibootz
1 answer 161 views
1 answer 168 views
1 answer 118 views
...