Created
August 23, 2019 04:45
-
-
Save hakaneroztekin/05e0ffc7f2aef3090108465e99345ef5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ArrayList | |
import java.util.*; | |
class TestJavaCollection1{ | |
public static void main(String args[]){ | |
ArrayList<String> list=new ArrayList<String>();//Creating arraylist | |
list.add("Ravi");//Adding object in arraylist | |
list.add("Vijay"); | |
list.add("Ravi"); | |
list.add("Ajay"); | |
// Traversing list through Iterator | |
Iterator itr=list.iterator(); | |
while(itr.hasNext()){ | |
System.out.println(itr.next()); | |
} | |
} | |
} | |
// Output: | |
// Ravi | |
// Vijay | |
// Ravi | |
// Ajay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment